相关疑难解决方法(0)

使用 Microsoft Graph 将文件上传到 SharePoint 驱动器

我们正在尝试使用 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;
Run Code Online (Sandbox Code Playgroud)

两者 …

sharepoint onedrive microsoft-graph-api

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

microsoft-graph-api ×1

onedrive ×1

sharepoint ×1