Microsoft 365 – Graph Explorer – How to find specific extension files in my drive (onedrive) – how to get ID of specific file from my drive
Hi All,
Greetings for the day!
We are exploring Microsoft Graph.
We have very good article series on Microsoft Graph. Kindly please have a look
- Microsoft Graph – https://knowledge-junction.in/category/technology-articles/m365/microsoft-graph/
- Graph Explorer – https://knowledge-junction.in/category/technology-articles/small-tricks-and-tips/graph-explorer/
- Microsoft Graph PowerShell – https://knowledge-junction.in/category/technology-articles/m365/microsoft-graph/microsoft-graph-powershell/
Today sharing simple query – find useful so thought to share.
Use Case / Background :
- I need to find my excel files which I uploaded / stored in my Onedrive
- Get ID of specific file from Onedrive – for example if I need require to get worksheets of my excel then to use Graph API query I need the ID of excel file from my drive
Details :
- Initial thought was to write PowerShell and get the report – which I’ll cover in next upcoming article – of course this we will require when we have large number of files in our drive
- But then I have few excels in my drive so thought to use GRAPH Explorer
Scenario 1 – Get all the excel files from my drive
Following are the excel files in my drive
Query :
https://graph.microsoft.com/v1.0/me/drive/root/search(q='.xlsx')?select=name,id,webUrl
Response :
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/root/microsoft.graph.search(q=<key>)?$select=audio,bundle",
"value": [
{
"@odata.type": "#microsoft.graph.driveItem",
"id": "01BGY4JJ34EISW27UVXRF3WOF3FEDEBOF6",
"name": "Book.xlsx",
"webUrl": "https://knowledgejunction1-my.sharepoint.com/personal/prasham_knowledgejunction1_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7B6D25227C-957E-4BBC-BB38-BB290640B8BE%7D&file=Book.xlsx&action=default&mobileredirect=true&DefaultItemOpen=1"
}
]
}
Here, we have one excel available so one record only
Scenario 2 – Get all the presentations from my drive
Following image shows all the presentations in my drive
Query :
https://graph.microsoft.com/v1.0/me/drive/root/search(q='.pptx')
Response:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/root/microsoft.graph.search(q=<key>)?$select=audio,bundle",
"value": [
{
"@odata.type": "#microsoft.graph.driveItem",
"createdDateTime": "2020-04-25T09:54:13Z",
"id": "01BGY4JJYEGD552R6LCFDJUQWDN3QI5WJF",
"lastModifiedDateTime": "2020-04-25T09:55:46Z",
"name": "Power Platform.pptx",
"webUrl": "https://knowledgejunction1-my.sharepoint.com/personal/prasham_knowledgejunction1_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BDDFB3004-CB47-4611-9A42-C36EE08ED925%7D&file=Power%20Platform.pptx&action=edit&mobileredirect=true&DefaultItemOpen=1",
"size": 365529,
"createdBy": {
"user": {
"email": "prasham@knowledgejunction1.onmicrosoft.com",
"displayName": "Prasham Sabadra"
}
},
"lastModifiedBy": {
"user": {
"email": "prasham@knowledgejunction1.onmicrosoft.com",
"displayName": "Prasham Sabadra"
}
},
"parentReference": {
"driveType": "business",
"driveId": "b!9_YyU-7_sE-dJ7aOJl59tD7be5VdGtpKopNhNYykD8UdESepcV3BQ6LOUM0nrEkO",
"id": "01BGY4JJYOJKRWBU6MARE2SKZDADKLJD5Z",
"siteId": "5332f6f7-ffee-4fb0-9d27-b68e265e7db4"
},
"file": {
"mimeType": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"hashes": {}
},
"fileSystemInfo": {
"createdDateTime": "2020-04-25T09:54:13Z",
"lastModifiedDateTime": "2020-04-25T09:55:46Z"
},
"searchResult": {},
"shared": {
"scope": "users"
}
}
Thanks for reading. HAVE a FANTASTIC LEARNING AHED ! LIFE IS BEAUTIFUL 🙂
You must be logged in to post a comment.