web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Hot to use "Queries" i...
Power Automate
Unanswered

Hot to use "Queries" in the http card

(0) ShareShare
ReportReport
Posted on by 4

I am getting data from a rest API in a flow.

 

I am attempting to retrieve a 'Department' from https://api.freshservice.com/v2/#list_all_departments

 

The Rest API returns all departments so I am them using a "For Each" to loop through the collection and get the item I am after.

 

I see in the HTTP Card there is an option for "Queries" but I can't find any documentation on it.

 

I am curious if I can use "Queries" to filter the data in the HTTP card and avoid the additional overhead of the "For Each" loop.

Categories:
I have the same question (0)
  • TaylorBecktold Profile Picture
    295 on at
    Re: Hot to use "Queries" in the http card

    Hey there -

     

    You are right, the documentation on these types of queries are difficult to find.

     

    I've utilized these frequently and this is the format I use: 

     

    HTTP Filter.png

     

    These two links should help you with further types of queries: 

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-connect-apps-filtering

    https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#97-filtering

     

    Just know that the first column should contain $filter and the second column should be your actual query. 

  • v-bacao-msft Profile Picture
    on at
    Re: Hot to use "Queries" in the http card

     

    Hi @ryanh1 ,

     

    You can directly use the attribute names in the collection to filter items. If the attribute type is string, you need to add single quotes outside the parameter.

    For example, I want to filter the channels in the specified Teams, and only want to get the channel whose display name is General.

    19.PNG

    In addition, you can also use Parse JSON to parse the response first, and then use the Filter array to filter the items.

    http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow

     

     

    Best Regards,

  • ryanh1 Profile Picture
    4 on at
    nRe: Hot to use "Queries" in the http card

    @v-bacao-msft

    @Taylor_Becktold 

     

    Thanks for the information, I have not found a reference to $filter anywhere! Clearly one of those hidden gems!

     

    I am not querying the Graph API, it's a FreshService API. Does the API endpoint need to support the $filter or is it run against the response?

     

    When I add:

    $filter | name eq 'Department 1'

     

    This is returned.

     

     

    {
     "description": "Validation failed",
     "errors": [
     {
     "field": "$filter",
     "message": "Unexpected/invalid field in request",
     "code": "invalid_field"
     }
     ]
    }

     

     

     

    For your reference this is an extract of the response I am trying to query/filter
     

     

    {
     "departments": [
     {
     "description": "",
     "custom_fields": {},
     "id": 01,
     "name": "Department 1",
     "created_at": "2019-06-26T07:18:05Z",
     "updated_at": "2019-07-30T12:06:04Z",
     "prime_user_id": 14000062291,
     "head_user_id": 14000062291,
     },
     {
     "description": "",
     "custom_fields": {},
     "id": 02,
     "name": "Department 2",
     "created_at": "2019-06-26T07:19:02Z",
     "updated_at": "2019-06-26T07:19:02Z",
     "prime_user_id": null,
     "head_user_id": null,
     }
     ]
    }

     

  • v-bacao-msft Profile Picture
    on at
    Re: nRe: Hot to use "Queries" in the http card

     

    Hi @ryanh1 ,

     

    Maybe you could use another method mentioned in my previous reply to achieve your needs.

    You could use Parse JSON to parse Response and use Filter array to filter items.

    Please take a try.

     

    Best  Regards,

  • ryanh1 Profile Picture
    4 on at
    Re: nRe: Hot to use "Queries" in the http card

    I can use Parse Json then filter, but that's 2 additional steps in a flow that is already dozens of steps long.

    I prefer to use Query if that's what it's there for (the purpose of this post initially)

     

    As I ask, is $filter needing to be supported by the endpoint it is the filter run against the response?

  • TaylorBecktold Profile Picture
    295 on at
    Re: nRe: Hot to use "Queries" in the http card

    @ryanh1 

     

    You'd need to reach out to Fresh Service and ask if they support the $filter. Looking at their public API documentation, you might not need the '$'. https://api.freshservice.com/v2/#best_practices

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard