我有一堆来自我的组织的共享链接(
https://mycorp.sharepoint.com/:x/:y/<some_folder>/<sharing_id>
我发现自己无法使用此技术从图形 api 获取文件:
GET https://graph.microsoft.com/v1.0/sites/mycorp.sharepoint.com:/sites/<some_folder>
GET https://graph.microsoft.com/v1.0/sites/{site_id}/drives
GET https://graph.microsoft.com/v1.0/sites/{site_id}/drives/{drive_id}/root:/<sharing_id>/content
我有什么遗漏的吗?
需要先展开分享链接见https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http
如果您使用 SDK,您需要首先对共享链接进行编码,然后您可以展开并从driveitem 获取下载网址,例如
string sharedlink = "https://xxxx-my.sharepoint.com/:w:/p/xxx/EXTw9StT51hKicApjyP3dQoBS2b8Z3FfaTv32Un5zeTbZA?e=ObtbwL";
string base64Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sharedlink));
string encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-');
var sharedFile = graphclient.Shares[encodedUrl].DriveItem.GetAsync().Result;
var fileurl = sharedFile.AdditionalData["@microsoft.graph.downloadUrl"].ToString();