架构扩展:“为资源“用户"的属性“公司名称"指定了不受支持或无效的查询过滤子句." [英] Schema Extensions : "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."
问题描述
我目前正在构建一个应用程序,该应用程序需要我根据自定义属性从 Graph API 检索用户,在这种情况下,extoe82ql2v_test/companyName
但到目前为止,API 以 为资源用户"的属性公司名称"指定的查询过滤子句不受支持或无效."
I'm currently building an application that requires me to retrieve users from the Graph API depending of a custom property, in that case, extoe82ql2v_test/companyName
but so far, the API responded with Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."
检索扩展的请求:
https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'extoe82ql2v_test'
结果:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
"value": [
{
"id": "extoe82ql2v_test",
"description": "Extend data for users",
"targetTypes": [
"User"
],
"status": "InDevelopment",
"owner": "d9a847ce-ca03-4779-88d6-c7e4f98297fe",
"properties": [
{
"name": "companyName",
"type": "String"
},
{
"name": "managerMail",
"type": "String"
},
{
"name": "arrivalDate",
"type": "DateTime"
},
{
"name": "expiryDate",
"type": "DateTime"
}
]
}
]
}
根据extoe82ql2v_test/companyName
检索用户的请求:
The request to retrieve the users depending of extoe82ql2v_test/companyName
:
https://graph.microsoft.com/v1.0/users?$select=extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled&$filter=extoe82ql2v_test/companyName eq 'test'
结果:
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
"innerError": {
"date": "2020-07-24T20:46:51",
"request-id": "639b8131-70dd-4436-b624-88167fe105eb"
}
}
}
与 Microsoft Graph .NET SDK 相同的查询:
var res = await _graphClient.Users.Request()
.Select($"extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled")
.Filter($"extoe82ql2v_test/companyName eq 'test'").GetAsync()
我不明白问题是什么,因为我遵循了 官方文档 说关于过滤自定义属性
I don't understand what the issue is as I followed what the official documentation said about filtering custom properties
非常感谢任何帮助
编辑 :这是 $select
没有 $filter
的样子
Edit : Here is how $select
without a $filter
looks like
请求:https://graph.microsoft.com/v1.0/users?$select=givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test
回应:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test)",
"value": [
{
"givenName": "Antoine",
"surname": "D",
"mail": "antoine.d@contoso.com",
"mobilePhone": null,
"department": null,
"companyName": null,
"accountEnabled": true,
"extoe82ql2v_test": {
"@odata.type": "#microsoft.graph.ComplexExtensionValue",
"expiryDate": "2020-12-31T00:00:00Z",
"arrivalDate": "2020-07-22T00:00:00Z",
"managerMail": "antoine.d@contoso.com",
"companyName": "test"
}
}
]
}
编辑 2:我使用另一个自定义属性成功过滤了用户,extoe82ql2v_test/managerMail
,这是一个进步,但我仍然需要在 extoe82ql2v_test/companyName
上应用过滤器并使其工作
Edit 2:
I successfully filtered the users with another custom attributes, extoe82ql2v_test/managerMail
, it's progress but I still need to apply a filter on extoe82ql2v_test/companyName
and make it works
编辑 3:过滤 extoe82ql2v_test/expiryDate
和 extoe82ql2v_test/arrivalDate
也有效,这两个属性都无法过滤,但至少我知道它们有效.至于extoe82ql2v_test/companyName
,不知是不是因为schema扩展和User
Graph对象都存在这个属性?
Edit 3:
Filtering on extoe82ql2v_test/expiryDate
and extoe82ql2v_test/arrivalDate
also works, both of these attributes are useless to filter but at least I know they work. As for extoe82ql2v_test/companyName
, I wonder if it is because this attribute exists in both the schema extensions and the User
Graph object ?
推荐答案
我刚刚遇到了同样的问题,并通过添加$count=true"使其工作.在查询参数中.
I just faced the same problem and made it work by adding "$count=true" in the query parameters.
我还注意到请求标头中似乎需要 ConsistencyLevel=eventual.
I also noticed it seems to need ConsistencyLevel=eventual in the request header.
例如:
https://graph.microsoft.com/v1.0/users?$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName
错误请求 - 400 - 146 毫秒
Bad Request - 400 - 146ms
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
...
}
https://graph.microsoft.com/v1.0/users?$count=true&$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName
(带有标头 ConsistencyLevel=eventual)https://graph.microsoft.com/v1.0/users?$count=true&$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName
(with header ConsistencyLevel=eventual)
OK - 200 - 404ms
OK - 200 - 404ms
o/
(我通过查看这个问题得到了提示 Microsoft Graph API 无法按公司名称过滤/users?)
(I got the hint by looking at this question Microsoft Graph API cannot filter /users by companyName?)
这篇关于架构扩展:“为资源“用户"的属性“公司名称"指定了不受支持或无效的查询过滤子句."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!