我们正在尝试使用Microsoft Graph rest API实现web应用程序和SharePoint Online之间的集成。
具体地说,我们需要将文件上传到特定SharePoint站点的文档库(驱动器),而不是当前用户默认的驱动器。我们通过Azure AD获得访问令牌,可以访问所有文件。
我们可以使用/v1.0/me/drive/...将文件上传到任何驱动器,但当我们使用其他驱动器时则不能。
例如:
var response = client.PutAsync(graphResourceUrl +
"/beta/sharepoint/sites/" + siteCollSiteId +
"/lists/" + listId +
"/drive/root/children/" + fileName + ":/content",
new ByteArrayContent(fileBytes)).Result;
var response = client.PutAsync(graphResourceUrl +
"/beta/drives/" + "/" + listId +
"/items/" + siteCollSiteId + "/" + fileName + ":/content",
new ByteArrayContent(fileBytes)).Result;
var response = client.PutAsync(graphResourceUrl +
"/beta/drives/" + listId + "/" + fileName + ":/content",
new ByteArrayContent(fileBytes)).Result;无论是/v1.0还是/beta (在SharePoint包含路径的情况下),我们都得到了Not Implemented的错误响应。
我们会做错什么呢?它是不是还不能使用微软的Graph (除了/me)?
发布于 2017-10-07 05:20:34
为了使用v1.0获取驱动器的所有文件,您首先需要获取一个访问令牌(我看到您已经传递了该令牌),然后获取' drive -id‘并使用以下URL(注意:不是'drive’,而是'drives'):
https://graph.microsoft.com/v1.0/drives/{drive-id}/root/children为了获取驱动器id,我使用postman发出了以下get请求,这将列出站点上的所有驱动器,您将能够获取该驱动器的ID:
https://graph.microsoft.com/v1.0/sites/{tenant}.sharepoint.com:{path-to-site(ie: /sites/HR)}:/drives要回答有关上传文件的问题,您需要向以下URL发出PUT请求:
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}/{file-name.txt}:/content您将需要设置两个必需的标头:
接下来,您将把文件的二进制流传递到请求的主体中。
其他有帮助的项目
获取文件夹中的所有文件:
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/children获取用户OneDrive的内容:
https://graph.microsoft.com/v1.0/me/drive/root/children发布于 2016-12-28 19:03:10
从:/content中删除驱动器通常我最好先获取sp库的驱动器,然后使用/ v1.0 / driveId /{driveId}在v1.0端点上工作
https://stackoverflow.com/questions/41285403
复制相似问题