0
votes

I successfully got my app to authenticate and download my list of sharepoint sites, and I can use that to walk into drives, and children and so on, but the JSON is very cryptic. For example, how can I turn this web URL:

https://microsoft.sharepoint.com/teams/Safe_CPS/Shared%20Documents/Forms/AllItems.aspx?id=%2Fteams%2FSafe%5FCPS%2FShared%20Documents%2FDrone%20Stack%2FTestProfile2%2Exml&parent=%2Fteams%2FSafe%5FCPS%2FShared%20Documents%2FDrone%20Stack&p=5

into this:

https://graph.microsoft.com/beta/sharepoint/sites/c5bc4bcc-1a63-4f39-8175-4f789765c0ed%2C97b22820-0d64-44e4-8290-017aad80869d/drives/b!ifHT_j-JO0aTZlD3jltBXq_EWiZO03dBiGffLyeoTwoxEhNiKNziRI42L5RTGFp9/root/...???

I don't want to have to search my way down this path trying to match webUrl properties as I go, that seems inefficient. Is there an API that "converts" the web url into the graph url efficiently ?

Also I'm asking for the children under the root it says childCount:22, but the children array comes back empty [], even when I pass the $expand=children query parameter? So I'm also stuck at this point trying to find a specific file...

1
Did you get any working solution for this which can be used in production environmentPooja Dhannawat

1 Answers

1
votes

Firstly find the driveId of the library you want to search. You can use paths:

GET https://graph.microsoft.com/beta/Sharepoint:/x/y/z/

You should get in reply

{"id":"12312-28c2-423f-bbb0-dd38120a51fa,435444-aa18-488b-8a73-ca9cdb1527fa",
"lastModifiedDateTime":"2016-12-28T11:33:37Z",
"name":"z",
"webUrl":"https://spsite.sharepoint.com/x/y/z",
"siteCollectionId":"12312-28c2-423f-bbb0-dd38120a51fa",
"siteId":"435444-aa18-488b-8a73-ca9cdb1527fa"}

Then use the id value to find the driveId

GET https://graph.microsoft.com/beta/Sharepoint/sites/12312-28c2-423f-bbb0-dd38120a51fa,435444-aa18-488b-8a73-ca9cdb1527fa/drives

{"@odata.context":"https://graph.microsoft.com/beta/$metadata#drives",
"value":[{"id":"b!0B8rf2IoP0K7sN04EgpR-ikpuEsYqotIinPKnNsVJ_r1nyBlP0qLS5tvm_JJzytW",
"driveType":"documentLibrary",
"owner":{"user":{}}}]}

Now use the drive graph api:)

GET https://graph.microsoft.com/v1.0/drive/b!0B8rf2IoP0K7sN04EgpR-ikpuEsYqotIinPKnNsVJ_r1nyBlP0qLS5tvm_JJzytW/root/children