OneDrive图形API - Checkin和Checkout无法工作

4

我正在尝试使用GraphApi和C#一起使用OneDrive来读取项目、上传项目等等,所有操作都正常工作。

我正在按照以下链接进行操作。 https://learn.microsoft.com/en-us/graph/api/driveitem-checkin?view=graph-rest-1.0&tabs=csharp

  [HttpPost]
  public async Task<IActionResult> Checkin(string Id)
  {
     //Id looks like this: B381F21397737D41!111

     var itemInfo = Id.Split('!');
     var versions = _graphServiceClient.Me.Drive.Items[Id].Versions.Request().GetAsync().Result;
     var permissions = _graphServiceClient.Me.Drive.Items[Id].Permissions.Request().GetAsync().Result;
     var drives = _graphServiceClient.Me.Drives.Request().GetAsync().Result;
  
     var comment = "Updating with the latest.";
     await _graphServiceClient.Drives[itemInfo[0]].Items[itemInfo[1]]
        .Checkin(null, comment)
        .Request()
        .PostAsync();

     return RedirectToAction("Index");
  }

但是当我进行签入或签出操作时,就会出现这个错误。直到异步的“签入”部分之前一切都很顺利。

ServiceException: Code: invalidRequest Message: API not found Inner 

error: AdditionalData: date: 2022-05-24T08:14:59 request-id: edac8ef2-13f5-46c9-aa1f-dcef248427aa client-request-id: edac8ef2-13f5-46c9-aa1f-dcef248427aa ClientRequestId: edac8ef2-13f5-46c9-aa1f-dcef248427aa
Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)

完整错误

这是因为签入/签出仅支持 beta 端点吗?

感谢任何帮助!


您使用的是哪种类型的OneDrive?个人版、商业版等等? - user2250152
@user2250152,主机应用正在使用商业账户,而登录的访客用户却拥有个人 Outlook 账户。 - Aby
其他代码问题:您有一个异步函数,但是您调用了.GetAsync().Result而不是await .GetAsync() - Oliver
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接