ms graph API - 如何使用 c# 中的图形客户端检出文件
ms graph API - how to check out a file using the graph client in c#
我正在尝试在使用图形客户端的 C# 应用程序中使用 MSGraph Explorer 复制这些经过测试(和工作)的查询:
Graph 资源管理器中的 HTTP 请求以签出 (sharepoint) 文件:
https://graph.microsoft.com/v1.0/sites/mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555/lists/12345ccc-1c9c-1c11-9e09-1cc1234bb0b4/items/2/driveItem/checkout
在上面的查询中,我假设站点 ID 是:
mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555
驱动器 ID 是:
12345ccc-1c9c-1c11-9e09-1cc1234bb0b4
问题
当我尝试在我的 C# 应用程序中签出文件时,出现以下错误:
Message: The provided drive id appears to be malformed, or does not
represent a valid drive.
c#代码
string mySiteId = "mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555";
string sharedDocsDriveId = "12345ccc-1c9c-1c11-9e09-1cc1234bb0b4";
string sharedFile.Id = "2";
await App.GraphClient.Sites[mySiteId].Drives[sharedDocsDriveId].Items[sharedFile.Id]
.Checkout()
.Request()
.PostAsync();
如有任何提示,我们将不胜感激。
编辑 1
由于这是共享点中的共享文档列表,我也尝试将 Drives 方法更改为这样的列表:
*/
await App.GraphClient.Sites[mySiteId].Lists[sharedDocsDriveId].Items[sharedFile.Id]
.Checkout()
.Request()
.PostAsync();
但是我得到一个错误,提示没有 Checkout() 方法:
Error
CS1061
'IListItemRequestBuilder' does not contain a definition for 'Checkout' and no accessible extension method 'Checkout' accepting a first argument of type 'IListItemRequestBuilder' could be found (are you missing a using directive or an assembly reference?)
找到解决方案:
await App.GraphClient.Sites[mySiteId].Lists[sharedDocsDriveId].Items[sharedFile.Id].DriveItem
.Checkout()
.Request()
.PostAsync();
我正在尝试在使用图形客户端的 C# 应用程序中使用 MSGraph Explorer 复制这些经过测试(和工作)的查询:
Graph 资源管理器中的 HTTP 请求以签出 (sharepoint) 文件:
https://graph.microsoft.com/v1.0/sites/mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555/lists/12345ccc-1c9c-1c11-9e09-1cc1234bb0b4/items/2/driveItem/checkout
在上面的查询中,我假设站点 ID 是:
mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555
驱动器 ID 是:
12345ccc-1c9c-1c11-9e09-1cc1234bb0b4
问题
当我尝试在我的 C# 应用程序中签出文件时,出现以下错误:
Message: The provided drive id appears to be malformed, or does not represent a valid drive.
c#代码
string mySiteId = "mySuperCoolDomainName.sharepoint.com,555b5555-5555-4555-5bb5-b555b55555b5,5555b555b-1234-123b1-83de-55b55b55555";
string sharedDocsDriveId = "12345ccc-1c9c-1c11-9e09-1cc1234bb0b4";
string sharedFile.Id = "2";
await App.GraphClient.Sites[mySiteId].Drives[sharedDocsDriveId].Items[sharedFile.Id]
.Checkout()
.Request()
.PostAsync();
如有任何提示,我们将不胜感激。
编辑 1
由于这是共享点中的共享文档列表,我也尝试将 Drives 方法更改为这样的列表:
*/
await App.GraphClient.Sites[mySiteId].Lists[sharedDocsDriveId].Items[sharedFile.Id]
.Checkout()
.Request()
.PostAsync();
但是我得到一个错误,提示没有 Checkout() 方法:
Error
CS1061
'IListItemRequestBuilder' does not contain a definition for 'Checkout' and no accessible extension method 'Checkout' accepting a first argument of type 'IListItemRequestBuilder' could be found (are you missing a using directive or an assembly reference?)
找到解决方案:
await App.GraphClient.Sites[mySiteId].Lists[sharedDocsDriveId].Items[sharedFile.Id].DriveItem
.Checkout()
.Request()
.PostAsync();