Microsoft Graph:将sharepoint网址转换为图形URI?

时间:2016-12-12 21:07:28

标签: microsoft-graph

我成功获得了我的应用程序进行身份验证并下载了我的sharepoint站点列表,我可以使用它来进入驱动器和孩子等等,但JSON非常神秘。例如,如何更改此网址:

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

进入这个:

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

我不想在这条路径上搜索我试图匹配webUrl属性,这似乎效率低下。是否存在"转换" web url有效地进入图表网址?

另外我要求root下的孩子们说childCount:22,但是当我传递$ expand = children查询参数时,children数组会返回空[]。所以我也在这一点上试图找到一个特定的文件...

1 个答案:

答案 0 :(得分:1)

首先找到要搜索的库的driveId。您可以使用路径:

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

你应该回复

{"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"}

然后使用id值查找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":{}}}]}

现在使用驱动图api:)

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