Microsoft Graph Api:按GUID值过滤 [英] Microsoft Graph Api: Filter by GUID value

查看:114
本文介绍了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": "admin@CIE493742.onmicrosoft.com",
    "mobilePhone": "+1 3528700812",
    "officeLocation": null,
    "preferredLanguage": "en-US",
    "surname": "Administrator",
    "userPrincipalName": "admin@CIE493742.onmicrosoft.com"
}

但是,就我而言,在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

返回以下消息:

检测到类型不兼容的二进制运算符.找到运算符类型等于"的操作数类型"Edm.String"和"Edm.Guid".

A binary operator with incompatible types was detected. Found operand types 'Edm.String' and 'Edm.Guid' for operator kind 'Equal'.

尝试两次

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

返回以下消息:

无法识别的'Edm.String'文字'guid'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7''位于'id eq guid'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7'中的'6'.

Unrecognized 'Edm.String' literal 'guid'f71f1f74-bf1f-4e6b-b266-c777ea76e2c7'' at '6' in '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值过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆