簡體   English   中英

如何使用 Microsoft Graph API SDK 在請求中添加 O.DataType?

[英]How to add O.DataType in request with Microsoft Graph API SDK?

我正在嘗試使用 Graph API 來獲取有關用戶權限的信息。 我可以使用此請求在圖形瀏覽器上以良好的格式檢索我想要的所有內容:

https://graph.microsoft.com/v1.0/users/{{UserId}}/transitiveMemberOf/microsoft.graph.group?$select=displayName,description

但是我不知道如何在 Graph API SDK 請求中翻譯 /microsoft.graph.group。 這就是我現在所擁有的:

await this._graphServiceClient.Users[userId].TransitiveMemberOf.Request().Select(this.GetQuery()).GetAsync();

有沒有辦法指定我只希望組為 OdataType?

我知道一旦請求完成,我可以過濾這種類型,但如果我不必這樣做,那就更好了。

There is no support for OData casting in Graph API dotnet sdk but some inspiration how to append microsoft.graph.group to request url can be found in msgraph-sdk-dotnet-contrib repository.

有一個WithODataCastMethod將 OData 轉換過濾器應用於返回的集合。

該方法的使用示例

await this._graphServiceClient.Users[userId]
    .TransitiveMemberOf
    .WithODataCastMethod("microsoft.graph.group")
    .Request()
    .Select(this.GetQuery())
    .GetAsync();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM