Reputation: 115
While learning graph API, I was trying to get a file from a SharePoint document library using Microsoft Graph API.
I first tried by accessing files in Documents
from https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com
by doing this GET request:
https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com/drive/root:/Test:/children
Everything worked great, I then tried accessing documents from another site within the same tenant. I told my self it was the same pathway while following the Microsoft docs.
I first did a test request to be sure i can first access to my site; here is what I did;
https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com:/sites/ObserveTestSite
On executing that query i got a 200 OK
response.
Secondly I then tried accessing the drive Documents
here is what i did;
https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com:/sites/ObserveTestSite:/drive
again everything worked fine.
I then used the root
relation followed by the name of the directory and then the children
relation; and this was my request:
https://graph.microsoft.com/v1.0/sites/tenant.sharepoint.com:/sites/ObserveTestSite:/drive/root:/Test:/children
But while executing that, I'm getting Bad Request - 400 - 96ms
Please help.
Thanks
Upvotes: 4
Views: 6760
Reputation: 3615
I have the same issue when using site relative url to specify the specific site.
Now I'm using siteId instead and everything works as expected:
https://graph.microsoft.com/v1.0/sites/zheguo.sharepoint.com,91a47a59-db5e-4d17-a689-479ee8905533,274459c9-4c96-42bf-9b96-838ffa387aaa/drive/root:/X:/children
Upvotes: 7