microsoft-graph-api - 有没有办法使用 C# SDK 从 Microsoft Graph API 获取已删除的目录项?
问题描述
有一个文档页面描述了我想要做的确切事情
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));
推荐阅读
- windows - Windows cmd 在链/多个命令中传递值
- javascript - 如何在 reactjs 中添加和删除选择框列表
- javascript - 制作一个输入按钮以在输入文本字段上强制执行所需的属性选项
- c++11 - 使用智能指针时出现分段错误
- javascript - 为什么 onScan 函数被调用两次?
- .htaccess - 如果存在文件,则重定向到某个文件,否则从 htaccess 重定向到 404
- firebase - Flutter 状态管理问题
- angular - 动态角度材料“选择”标签上的 setValue 不起作用
- java - 应用程序失败:膨胀类 com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch 时出错
- javascript - 我将带有 Google 地图的网站转换为 Android 应用程序。谷歌地图未显示在 Android 应用程序中