Schema Extensions : "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'." - microsoft-graph-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'."
The request to retrieve the extension :
https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'extoe82ql2v_test'
The result :
{
"#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"
}
]
}
]
}
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'
The result :
{
"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"
}
}
}
The same query with the 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
Any help is greatly appreciated
Edit : Here is how $select without a $filter looks like
Request :
https://graph.microsoft.com/v1.0/users?$select=givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test
Response :
{
"#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"
}
}
]
}
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
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 ?

I just faced the same problem and made it work by adding "$count=true" in the query parameters.
I also noticed it seems to need ConsistencyLevel=eventual in the request header.
For example:
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 (with header ConsistencyLevel=eventual)
OK - 200 - 404ms
\o/
(I got the hint by looking at this question Microsoft Graph API cannot filter /users by companyName?)

Related

Unable to update columnDefinition of an existing column in Sharepoint list using graphApi - BadRequest error

Sample payload:
{
"text": {
"maxLength": 1000
}
}
And my PATCH Url is
https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
I am providing the usual headers
Accept: application/json
Content-Type: application/json
And
Authorization: Bearer Token....
I get BadRequest error
{
"error": {
"code": "invalidRequest",
"message": "One of the provided arguments is not acceptable.",
"innerError": {
"code": "badArgument",
"date": "2023-01-30T16:34:49",
"request-id": "b63137f9-fda0-41b7-9549-5952b5c89427",
"client-request-id": "b63137f9-fda0-41b7-9549-5952b5c89427"
}
}
}
I tried adding "propagateChanges": true to the payload and I get slightly different error
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"date": "2023-01-30T16:39:37",
"request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c",
"client-request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c"
}
}
}
Any help is appreciated.
NOTE: I am able to update for e.g. Description of the column, but not the text.maxLength property.
The maximum length of a SharePoint text field type is 255, you cannot set it to 1000. If you try setting the max length to 200 for example instead of 1000, your query should succeed.
To allow longer strings, you have to use the "note" ("multiline text") field type, not "text". This one has a limit of 63,999.
I am not sure if you can change column type using graph api (you cannot as far as I remember, but I am not 100% sure), you may need to re-create that column as "multiline", change manually, use the classic rest api instead of graph api to do it programmatically, or something like a powershell script.
If you have textColumn and allowMultipleLines is set to false then you have one line text column and the maximum length is 255.
It's not possible to change column type from one line text to multiple lines text via Graph API.
Call
PATCH https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
{
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}
Will fail.
You have to create a new column and define it as multiple lines. Define textColumn and set allowMultipleLines to true.
POST https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns
{
"description": "",
"displayName": "Column XXX",
"enforceUniqueValues": false,
"hidden": false,
"indexed": false,
"name": "My new multiple lines column",
"readOnly": false,
"required": false,
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}

Hasura query action exception

Got a small problem (I guess). I created c# rest web API on docker swarm environment. Rest API is working properly - tested via the postman. Then I tried to compose Hasura service on the same docker swarm environment. The console is working properly also. The problem is with query action.
Code:
Action definition:
type Query {
getWeatherForecast : [WeatherForecastResonse]
}
New types definition:
type WeatherForecastResonse {
date : String
temperatureC : Int
temperature : Int
summary : String
}
Handler:
http://{api ip}:{api port}/WeatherForecast
While trying to execute query:
query MyQuery {
getWeatherForecast {
temperature
summary
date
temperatureC
}
}
All I got from response is error with json:
{
"errors": [
{
"extensions": {
"internal": {
"error": "invalid json: Error in $: not enough input",
"response": {
"status": 405,
"body": "",
"headers": [
{
"value": "Mon, 14 Jun 2021 13:54:00 GMT",
"name": "Date"
},
{
"value": "Kestrel",
"name": "Server"
},
{
"value": "0",
"name": "Content-Length"
},
{
"value": "GET",
"name": "Allow"
}
]
},
"request": {
"body": {
"session_variables": {
"x-hasura-role": "admin"
},
"input": {},
"action": {
"name": "getWeatherForecast"
}
},
"url": "http://{api ip}:{api port}/WeatherForecast",
"headers": []
}
},
"path": "$",
"code": "unexpected"
},
"message": "not a valid json response from webhook"
}
]
}
I got desired response by using postman white calling: http://{api ip}:{api port}/WeatherForecast (GET method)
Where should I improve, to finally get desired result from rest api?
P.S. hasura version: v2.0.0-alpha.4 (tried also with v1.3.3)
UPDATE:
Released a new version of web API. Inside WeatherForecastController included a new method with POST attribute. Query remained the same, but now graphql query returns what I want.
So the question is: Is it possible to call/access web api methods with GET attribute with Hasura action query?
From the version v2.1.0 and above we can do this using the REST Connectors.Hasura Actions RESTConnectors Methods
Go to the Actions tab on the console and create or modify an action. Scroll down to Configure REST Connectors.
In the Configure REST Connectors section, click on Add Request Options Transform
Along with this you can do a lot of other configurations.
No, currently it's not possible, Hasura always makes POST requests to the action handler:
When the action is executed i.e. when the query or the mutation is called, Hasura makes a POST request to the handler with the action arguments and the session variables.
Source: https://hasura.io/docs/latest/graphql/core/actions/action-handlers.html#http-handler

How to fetch "#microsoft.graph.downloadUrl" from Microsoft Search API?

I am using Microsoft Search API to search for files in SharePoint, objective is to fetch temporary url ("#microsoft.graph.downloadUrl") amoung other fields. I have used below search request,
Url - POST request: https://graph.microsoft.com/v1.0/search/query
Body:
{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "search-value",
"query": "path:\"https://{company}.sharepoint.com/sites/{site}/shared\""
},
"fields": [
"name",
"webUrl",
"#microsoft.graph.downloadUrl"
]
}
]
}
The result returned is below, and it is missing "#microsoft.graph.downloadUrl" field.
"moreResultsAvailable": false,
"hits": [
{
"hitId": "01CDLPULQVGFRNVHYTJVFL3NPPXIGOUDUS",
"rank": 1,
"summary": "string;#<c0>search-value</c0> <c0>search-value</c0> Internal 1 0 search-value Graph explorer {DA623115<ddd/>",
"resource": {
"#odata.type": "#microsoft.graph.driveItem",
"name": "word.docx",
"webUrl": "https://company.sharepoint.com/sites/{site}/Cases/search-value/word.docx"
}
},
Search API can retrieve only properties but not instance attributes like "#microsoft.graph.downloadUrl".
Properties
Instance attributes
I think there's no need to use the REST API. To get the temporary #microsoft.graph.downloadUrl download link I used the following to get the value:
var selectedFile = files.value[0];
var downloadLink = selectedFile["#microsoft.graph.downloadUrl"];
Found at this link: https://github.com/OneDrive/onedrive-api-docs/issues/547
I hope this helps

Cannot create contact with custom data in schema extensions, group works

I have created a schema extension for group and contacts.
First Issue: I can create new group with custom data using the extension but not with contact. I get the following error when I try to create a new contact with custom data in schema extension.
{
"error":
{
"code": "RequestBodyRead",
"message": "The property 'extcivhhslh_sbtest1' does not exist on type 'Microsoft.OutlookServices.Contact'. Make sure to only use property names that are defined by the type or mark the type as open type.",
"innerError":
{
"request-id": "5686a76f-f016-47aa-82a3-acd9ab57e3ae",
"date": "2017-06-14T05:44:22"
}
}
}
Issue#2: As per the 5th example in https://developer.microsoft.com/en-us/graph/docs/concepts/extensibility_schema_groups I should be able to get the custom data in the extensions. In my testing I don't get back the custom data in the extension.
The extension looks like the following:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
"value": [
{
"id": "extcivhhslh_sbtest1",
"description": "SbGraph test extensions",
"targetTypes": [
"contact",
"group"
],
"status": "Available",
"owner": "da033fe6-d48e-435d-8014-e98a4b166900",
"properties": [
{
"name": "customerType",
"type": "String"
}
]
}
]
}
1 - Schema extensions cannot be used while creating the contact. Once the contact is created, you can patch it using schema extension value.
2 - Please verify that you have specified $select=extcivhhslh_sbtest1 while querying for /groups to get the extension values (along with other $select properties that you are interested in).
Thanks,
Pavan

Can I query for Estimates with NULL ClassRef in Quickbooks API v3?

According to the documents, you should be able to query for NULL ClassRef values like so:
select * from Estimate where ClassRef = ' '
But, that query is causing a validation error:
{
"Fault": {
"Error": [
{
"Message": "Invalid ID",
"Detail": "Id should be a valid number. Supplied value: ",
"code": "2030",
"element": "ClassRef"
}
],
"type": "ValidationFault"
},
"time": "2014-06-19T12:34:43.37-07:00"
}
How can I query for null ClassRefs?
No you can't search by ClassRef because it is not a filterable attribute for the Estimate entity.
References:
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/estimate
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/00300_query_operations

Resources