Dave
Dave

Reputation: 898

Why does Microsoft Graph filter works in graph explorer but not in API

I'm looking to apply a filter to the users endpoint, this works in the Graph Explorer:

https://graph.microsoft.com/v1.0/users?$count=true&$filter=endsWith(mail,'domain.co.uk')

enter image description here

but running over the API it returns Unsupported Query If it's not supported why does it work in the Graph Explorer?

my code for refernece:

$response = $client->get("https://graph.microsoft.com/v1.0/users?\$count=true&\$filter=endsWith(mail,'domain.co.uk')", [
    'headers' => [
        'Authorization' => 'Bearer xxxtoken',
        'content-type' => 'application/json'
    ]
]);

Upvotes: 2

Views: 3828

Answers (1)

Joy Wang
Joy Wang

Reputation: 42043

Well, I can also reproduce your issue in the postman.

enter image description here

The trick is that you need to add the ConsistencyLevel = eventual in the request header when you use the advanced query capabilities, then it will work fine, in your code, it should be 'ConsistencyLevel' => 'eventual'. (BTW, content-type is not needed in this case)

enter image description here

Upvotes: 3

Related Questions