1
votes

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'
    ]
]);
1
Double check that query, it doesn't work in Graph Explorer for me. I get the same error you get when invoking from your code.PMental
I've added a screenshot of it working for me on the explorer.Dave
Really strange, I get a 400 Response with the message "Unsupported Query" when I try the exact same request in Graph Explorer. Tried both 1.0 and beta, same result.PMental
yeah I don't get it either.Dave
Ok so I've tried some filters (via API calls, not through Graph Explorer), and startsWith works fine, but endsWith does not work at all, I tried it with other stuff like displayName etc. and it's always the same error. I'd say it's a bug, something is off.PMental

1 Answers

2
votes

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