Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

Get data from HTTP response without ‘Parse JSON’ in Power Automate

Posted on February 7, 2021October 6, 2021 by Tom

“‘Parse JSON’ gives me a lot of useless dynamic contents, is there another way to parse the response from an HTTP request in Power Automate?”


When using HTTP requests in Power Automate, it’s recommended to use the ‘Parse JSON’ action to process the response. You take the HTTP response, use it as a sample payload in the ‘Parse JSON’, and the action will parse it for you. But if you do that, it’ll give you much more dynamic contents than you’d expect. It’ll parse everything in the HTTP response and add a ton of dynamic content, sometimes even doubling it. So, is there an easier way to get the data you need without using ‘Parse JSON’?

Power Automate http request parse json output

Access the data using expressions

When you look at the response from the HTTP request, you can see it’s a valid JSON. Let’s take an example, a response from an HTTP call that will return list of users in a SharePoint group.

_api/Web/SiteGroups/GetByID([ItemID])/users
Power Automate http request to get
Power Automate http request output

The body of the example response will look as above. There’s the main element “d” (1), subelement “results” (2) with an array of users, and the actual user data (3). You can recognize that “results” is an array by the square brackets [ ] enclosing the user information (3). Since you’re interested in the user data, you want to loop through all the “results” and get the desired value for each user.

Expression to access the array

The first step is to get only the “results’ array from the object, and then use it in an ‘Apply to each’ action to process all items (users). Start from the default ‘body’ output from the HTTP action, it’ll look like: outputs(‘HTTP request action name’)?[‘body’], e.g. as below.

outputs('Send_an_HTTP_request_to_SharePoint')?['body']

This dynamic content contains all the data as shown on the image above. But as was already mentioned, you need to go deeper, you want to go in the “d” and “results” elements.

outputs('Send_an_HTTP_request_to_SharePoint')?['body']['d']['results']

That’s the expression to use as the input of the ‘Apply to each’ action that will loop through all the results.

loop through http output array

Expression to access the value

Now it’s time to select the value you want to get from that array. When processing an array inside ‘Apply to each’, you can access the currently processed item with item() expression. To continue with the example from above, each item() will contain only the part 3.

user data in http response

You’ll define what value from the item() you want by adding its key to the item() expression in the format below:

item()?['Key']

e.g. to get user Email address
item()?['Email']

And that’s the expression you can use to access the desired value from an HTTP request response, in this example the user email.

power automate process http request output

Summary

I’d say that’s the key takeaway from this article is to think about any input of ‘Parse JSON’ as an object. If it needs parsing, it’s an object and you can do all the object operations with it.

‘Parse JSON’ will just parse it for you and make the use more convenient, but it’s not the only way. You can skip that action and do the parsing by yourself, take only the values you really need and leave the rest. And it doesn’t apply only to HTTP requests, you can extract data from any JSON.

Also, the HTTP request in this article was taken just as an example. You can follow the same process with minor variations for any HTTP request and its outcome. It’s just another object after all.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

6 thoughts on “Get data from HTTP response without ‘Parse JSON’ in Power Automate”

  1. Matt Harding says:
    June 16, 2022 at 1:56 pm

    Really useful article, I find the Parse JSON Step to be less than ideal for complex schemas because you lose the structure of the JSON, for example ID could appear 10 times in a big response, the parse step doesn’t show the path like “Product > Sales > ID” for example, you just get ID with no lineage. I prefer this method of deconstructing the JSON like this.

    Reply
    1. Tom says:
      June 22, 2022 at 8:57 pm

      Hello Matt,
      I agree, I don’t like the Parse JSON exactly for the same reason, it creates a terrible mess among the dynamic contents. I don’t even remember the last time I used it since it’s so easy to get the right value right away…

      Reply
  2. Karthik Kota says:
    June 24, 2022 at 5:34 am

    Awesome, thanks!

    Reply
    1. Karthik Kota says:
      June 24, 2022 at 5:35 am

      I mean thanks to the author of the post Tom.

      Reply
  3. Christine says:
    December 7, 2022 at 4:17 am

    Hi Tom – I got the cheat sheet but there’s nothing in it on GET an item. I have some fairly complex processes and the multiple date and person fields don’t come through in a simple Get Item/Get Items action. I got the cheat sheet hoping it would contain information on how to get an item and that maybe that way I could circumvent the limitation on complex fields that Get Item has.

    Apart from single parameters, would an HTTP action help me with that?

    Thanks, Christine

    Reply
    1. Tom says:
      December 7, 2022 at 1:26 pm

      Hello Christine,
      you can use an HTTP request in the format ‘_api/web/lists/getByTitle(‘listName’)/items’ to get the items with all the columns, but I don’t think it’s a “user friendly” approach, especially for people picker columns as it’ll return only user Id on the specific site, not the AD connected object like the ‘Get item/Get items’ action.
      In general I think that the ‘Get items/Get item’ actions are much better than the HTTP alternatives, even if you have to use multiple ‘Get items’ over different views to get all the columns and merge them together into a single array (a topic Paul wrote a nice article about: https://www.tachytelic.net/2022/07/power-automate-merge-array/)

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes