我正在尝试操作存储在我们的intranet Sharepoint服务器上的Excel工作簿
https://xyz.ourserver.com/sites/site/list/subdir/Test.xlsx
这是我到目前为止得到的API用法(我猜/希望这可以更容易完成,但目前我只是在探索):
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将返回一个空集合:
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“。
发布于 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")。
使用这些设置,此代码可以工作:
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();https://stackoverflow.com/questions/60604031
复制相似问题