cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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 blog

Power 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
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (26,913)