本文介绍了Microsoft Graph Api:按GUID值过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Microsoft Graph Api来获取特定用户的详细信息.

I am trying to use Microsoft Graph Api to get the details of a specific user.

我有一个可以使用图形浏览器演示的问题: https: //developer.microsoft.com/zh-CN/graph/graph-explorer

I have a problem that can be demonstrated using the Graph Explorer: https://developer.microsoft.com/en-us/graph/graph-explorer

如果我运行此查询:

https://graph.microsoft.com/v1.0/users

我得到了一个用户列表,包括他们的ID.

I get a list of users, including their ID.

我知道我可以通过将id附加到url来获得一个用户的详细信息.例如,此查询:

I know I can get the details of just one user by appending the id to the url. For example, this query:

https://graph.microsoft.com/v1.0/users/f71f1f74-bf1f-4e6b-b266-c777ea76e2c7

产生一个特定用户的详细信息.

Results in the details of one specific user.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "id": "f71f1f74-bf1f-4e6b-b266-c777ea76e2c7",
    "businessPhones": [],
    "displayName": "CIE Administrator",
    "givenName": "CIE",
    "jobTitle": null,
    "mail": "[email protected]",
    "mobilePhone": "+1 3528700812",
    "officeLocation": null,
    "preferredLanguage": "en-US",
    "surname": "Administrator",
    "userPrincipalName": "[email protected]"
}

但是,就我而言,在id字段上应用$filter查询会更容易.

However, in my case, it would be easier to apply a $filter query on the id field.

这是我尝试过的,并且得到的错误:

Here is what I have tried, and the errors I get:

.../users?$filter=id eq f71f1f74-bf1f-4e6b-b266-c777ea76e2c7

返回以下消息:

尝试两次

..../users/$filter=id eq guid'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7'

返回以下消息:

推荐答案

最后弄清楚了.

只需将Guid用单引号引起来,而无需其他注释.

Simply wrap the guid in single quotes, with no other annotations.

https://graph.microsoft.com/v1.0/users?$filter=id eq 'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7'

这篇关于Microsoft Graph Api:按GUID值过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 14:17