cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kubalaml
Helper II
Helper II

Call Graph API with filter in query string

I'm trying to use the HTTP action to make a call to the Microsoft Graph API to query all active AD users using a certain filter. I've setup the application and bearer token already. It works if I make a call to just the users endpoint (https://graph.microsoft.com/v1.0/users) like this:

 

kubalaml_0-1606339431980.png

But when adding in a filter like this:

 

https://graph.microsoft.com/v1.0/users?$filter=endsWith(mail,'company.com') and JobTitle ne null&$select=userPrincipalName

 

It says "Enter a valid URI"

 

kubalaml_1-1606339862588.png

 

I've added this URI to a variable to get around the error, but when it runs it says "Unsupported Query"

 

"error": {
    "code""Request_UnsupportedQuery",
    "message""Unsupported Query.",
 
I see that there is a Queries section on the HTTP action, but I haven't figured out what format to put my query in to get it to work. 
 
Also I already tested this query in the graph explorer and it works so the problem is not there.
 
Thanks for your help.

 

1 ACCEPTED SOLUTION

Accepted Solutions

So part of the issue is that you need to use a variable for the URL. You can do the whole URL or just the query string as suggested above. The other bigger issue is that there seems to be a bug with Power Automate and how it handles filters. If I use 'endswith' or do a comparison against null (ex: 'mail eq null'), then it throws an error, but these works just fine using the Graph Explorer. My work around was to just run the query using the filters that do work, then use the Filter Array action to filter the contents further. 

View solution in original post

2 REPLIES 2
abm
Super User III
Super User III

Hi @kubalaml 

 

You need to add a new string variable and enter the below as value

 

?$filter=endsWith(mail,'company.com') and JobTitle ne null &$select=userPrincipalName

 

Map this under the end of url

 

Please see this article explains about the issue

 

Combining Microsoft Graph and Flow for Better Office 365 Adminstration - Office 365 for IT Pros (off...



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

So part of the issue is that you need to use a variable for the URL. You can do the whole URL or just the query string as suggested above. The other bigger issue is that there seems to be a bug with Power Automate and how it handles filters. If I use 'endswith' or do a comparison against null (ex: 'mail eq null'), then it throws an error, but these works just fine using the Graph Explorer. My work around was to just run the query using the filters that do work, then use the Filter Array action to filter the contents further. 

View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Users online (68,660)