gpt4 book ai didi

microsoft-graph-api - 架构扩展 : "Unsupported or invalid query filter clause specified for property ' companyName' of resource 'User' .“

转载 作者:行者123 更新时间:2023-12-05 06:14:04 24 4
gpt4 key购买 nike

我目前正在构建一个应用程序,它要求我根据自定义属性从 Graph API 检索用户,在这种情况下,extoe82ql2v_test/companyName 但到目前为止,API 响应为 为资源“用户”的属性“公司名称”指定的查询过滤器子句不受支持或无效。”

检索扩展的请求:

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检索用户的请求:

https://graph.microsoft.com/v1.0/users?$select=extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled&$filter=extoe82ql2v_test/companyName eq '测试'

结果:

{
"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()

我不明白问题是什么,因为我遵循了 official documentation 的内容说到过滤自定义属性

非常感谢任何帮助

编辑:这是没有$filter$select的样子

请求: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 上应用过滤器并使其工作

编辑 3:在 extoe82ql2v_test/expiryDateextoe82ql2v_test/arrivalDate 上过滤也有效,这两个属性都无法过滤但至少我知道它们有效。至于extoe82ql2v_test/companyName,我想知道是不是因为这个属性同时存在于schema extensions和User Graph对象中?

最佳答案

我刚刚遇到了同样的问题,并通过在查询参数中添加“$count=true”使其工作。

我还注意到它似乎需要在请求 header 中使用 ConsistencyLevel=eventual

例如:

  • https://graph.microsoft.com/v1.0/users?$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName

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)

OK - 200 - 404ms

\o/

(我通过查看这个问题得到了提示 Microsoft Graph API cannot filter /users by companyName? )

关于microsoft-graph-api - 架构扩展 : "Unsupported or invalid query filter clause specified for property ' companyName' of resource 'User' .“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63081403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com