首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过Microsoft Graph导航到存储在Sharepoint上的工作簿

通过Microsoft Graph导航到存储在Sharepoint上的工作簿
EN

Stack Overflow用户
提问于 2020-03-09 23:45:58
回答 1查看 29关注 0票数 0

我正在尝试操作存储在我们的intranet Sharepoint服务器上的Excel工作簿

https://xyz.ourserver.com/sites/site/list/subdir/Test.xlsx

这是我到目前为止得到的API用法(我猜/希望这可以更容易完成,但目前我只是在探索):

代码语言:javascript
复制
var site = await graphClient
    .Sites["xyz.ourserver.com"]
    .SiteWithPath("sites/site")
    .Request()
    .GetAsync();

var list = await graphClient
    .Sites[site.Id]
    .Lists["list"]
    .Request()
    .GetAsync();

var driveItems = await graphClient
    .Sites[site.Id]
    .Lists[list.Id]
    .Drive
    .Root
    .ItemWithPath("/subdir")
    .Children
    .Request()
    .GetAsync();

步骤1+2(获取站点和列表)工作正常,但步骤3抛出"itemNotFound消息:无法找到资源“。

当然,我尝试过很多不同的版本。此外,此替代步骤3将返回一个空集合:

代码语言:javascript
复制
var children = await graphClient
    .Sites[site.Id]
    .Lists[list.Id]
    .Drive
    .Root
    .Children
    .Request()
    .GetAsync();

"subdir“肯定存在(test.xlsx也是如此)。我也非常确定这个列表是正确的,它有WebUrl属性"https://xyz.ourserver.com/sites/site/list“。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-10 18:32:57

这是一个许可问题。当我比较(看起来不错) Graph Explorer的json结果和应用程序接收的(空的) json结果(我在Fiddler中检查了它)时,这一点变得很明显。

我使用了这个图形教程(https://github.com/microsoftgraph/msgraph-training-aspnetmvcapp)来探索Graph API。应用程序权限已经正确设置,但我不知道PrivateSettings.config还需要额外的"ida:AppScopes“(在我的例子中是: value="User.Read Calendars.Read Files.Read Files.ReadWrite Files.Read.All Files.ReadWrite.All Sites.Read.All Sites.ReadWrite.All")。

使用这些设置,此代码可以工作:

代码语言:javascript
复制
var drive = await graphClient
    .Sites["rwe.sharepoint.com"]
    .SiteWithPath("sites/site")
    .Lists["list"]
    .Drive
    .Request()
    .GetAsync();

var driveItems = await graphClient
    .Drives[drive.Id]
    .Root
    .ItemWithPath("subdir")
    .Children
    .Request()
    .GetAsync();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60604031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档