[英]Cannot Access DeletedItems through Microsoft.Graph
我嘗試通過Microsoft Graph訪問DeletedItems 。
這是我的代碼:
graphClient
.Directory
.DeletedItems[userid]
.Request()
.GetAsync();
我收到以下異常響應:
Code: BadRequest.
Message: Resource not found for the segment 'directory'.
有人知道如何正確訪問deletedItems
嗎? 我是否缺少訪問它的內容?
此特定調用有點不尋常,因為所使用的ID實際上不是用戶ID,而是對象類型或objectId。 因此,要獲取已刪除項目的列表,請在數組索引中傳遞類型。
例如
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
上面的代碼演示了一種簡便的方法,可以准確地查看庫嘗試發送的HTTP請求。 它需要拉入Microsoft.AspNet.WebApi.Client
Nuget以獲得HttpMessageContent
對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.