简体   繁体   English

无法通过Microsoft.Graph访问DeletedItems

[英]Cannot Access DeletedItems through Microsoft.Graph

I try to access the DeletedItems via Microsoft Graph. 我尝试通过Microsoft Graph访问DeletedItems

Here is my code: 这是我的代码:

graphClient
  .Directory
  .DeletedItems[userid]
  .Request()
  .GetAsync();

I receive this exception response: 我收到以下异常响应:

Code: BadRequest. 
Message: Resource not found for the segment 'directory'. 

Anyone knows how to access deletedItems correctly? 有人知道如何正确访问deletedItems吗? Am I missing something to access it? 我是否缺少访问它的内容?

This particular call is a little unusual in that the Id that is used is not actually the user Id, but is object type or objectId. 此特定调用有点不寻常,因为所使用的ID实际上不是用户ID,而是对象类型或objectId。 So to get a list of deleted items, you pass the type in the array index. 因此,要获取已删除项目的列表,请在数组索引中传递类型。

eg 例如

var graphClient = new GraphServiceClient(null);

var request = graphClient
      .Directory
      .DeletedItems["microsoft.graph.user"]
      .Request()
      .GetHttpRequestMessage();

var content = new HttpMessageContent(request);
Console.Write(content.ReadAsStringAsync().Result);
Console.Read();


Output:

GET /v1.0/directory/deletedItems/microsoft.graph.user HTTP/1.1
Host: graph.microsoft.com
SdkVersion: Graph-dotnet-1.13.0

The above code demonstrates a handy way of seeing exactly what HTTP request the library is attempting to send. 上面的代码演示了一种简便的方法,可以准确地查看库尝试发送的HTTP请求。 It requires pulling in the Microsoft.AspNet.WebApi.Client Nuget to get the HttpMessageContent object. 它需要拉入Microsoft.AspNet.WebApi.Client Nuget以获得HttpMessageContent对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM