有没有办法使用 C# SDK 从 Microsoft Graph API 获取已删除的目录项?
Is there a way to get the deleted directory items from Microsoft Graph API using the C# SDK?
有一个文档页面描述了我想要做的事情
https://docs.microsoft.com/en-us/graph/api/directory-deleteditems-list?view=graph-rest-1.0&tabs=http
但是,在 C# 中检索此数据的建议方法是
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var group = await graphClient.Directory.DeletedItems
.Request()
.GetAsync();
我尝试使用它,但由于未指定要查看的项目类型而收到错误请求错误。我似乎找不到在 C# SDK 中指定它的方法。
作为参考,这是 Java SDK 中的做法
IGroupCollectionPage group = graphClient.directory().deletedItems().microsoft.graph.group()
.buildRequest()
.get();
Github 中提出了类似的问题,我们会相应地向您更新
要解决此问题,您可以使用以下代码
var deletedGroupReq = await graphClient.Directory.DeletedItems["microsoft.graph.group"]
.Request()
.Select("DisplayName,DeletedDateTime")
.GetAsync();
var deletedGroups = graphClient.HttpProvider.Serializer.DeserializeObject<IGraphServiceGroupsCollectionPage>(deletedGroupReq.AdditionalData["value"].ToString());
Console.WriteLine(JsonConvert.SerializeObject(deletedGroups));
有一个文档页面描述了我想要做的事情
https://docs.microsoft.com/en-us/graph/api/directory-deleteditems-list?view=graph-rest-1.0&tabs=http
但是,在 C# 中检索此数据的建议方法是
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var group = await graphClient.Directory.DeletedItems
.Request()
.GetAsync();
我尝试使用它,但由于未指定要查看的项目类型而收到错误请求错误。我似乎找不到在 C# SDK 中指定它的方法。
作为参考,这是 Java SDK 中的做法
IGroupCollectionPage group = graphClient.directory().deletedItems().microsoft.graph.group()
.buildRequest()
.get();
Github 中提出了类似的问题,我们会相应地向您更新
要解决此问题,您可以使用以下代码
var deletedGroupReq = await graphClient.Directory.DeletedItems["microsoft.graph.group"]
.Request()
.Select("DisplayName,DeletedDateTime")
.GetAsync();
var deletedGroups = graphClient.HttpProvider.Serializer.DeserializeObject<IGraphServiceGroupsCollectionPage>(deletedGroupReq.AdditionalData["value"].ToString());
Console.WriteLine(JsonConvert.SerializeObject(deletedGroups));