I'm trying to get the folders and documents from a SharePoint document library using Microsoft Graph API.
If I do a GET
request for https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/
, I get this back:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value":[
{
"createdDateTime": "2019-09-05T07:09:49Z",
"description": "",
"id": "b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX",
"lastModifiedDateTime": "2019-09-05T07:09:49Z",
"name": "Documents",
"webUrl": "https://mysite.sharepoint.com/sites/MyDocumentSite/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy":{"user":{"displayName": "System Account" }},
"lastModifiedBy":{"user":{"email": "[email protected]", "id": "73f9990c-5c92-4839-8b13-XXXXXXXXXXXX", "displayName": "John Smith"…},
"quota":{"deleted": 0, "remaining": 0, "total": 0, "used": 0}
}
]
}
But if I try to access that drive by doing a GET
request on that id: https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX
, I get a BadRequest error:
{
"error":{
"code": "BadRequest",
"message": "Url specified is invalid.",
"innerError":{
"request-id": "7c9eaf61-764f-4d72-abdb-ffa2fe868e90",
"date": "2019-09-16T19:09:41"
}
}
}
Ultimately, I want a way to display all folders and documents from the document library but I can't seem to get past this initial step.