Parse JSON in Power Automate

In today’s post I’ll be showing you how to use Parse JSON in Power Automate to make using things like HTTP requests easier by creating dynamic content to use in subsequent places in your flow! The problem So, when we use things like a… READ MORE [https://lewisdoes.dev/blog/parse-json-in-power-au
man love people woman
Photo by RealToughCandy.com on Pexels.com
In: Low Code Lewis Content 🚀

In today’s post I’ll be showing you how to use Parse JSON in Power Automate to make using things like HTTP requests easier by creating dynamic content to use in subsequent places in your flow!

The problem

So, when we use things like a HTTP request to call an API and execute a GET call on it, Power Automate doesn’t know the format that the data will be returned in, so it isn’t able to produce dynamic content for us to use when we’re building our flow. It only knows what the data looks like once the call has been made. This isn’t good enough for when we’re building our flow though.

So, now we have no dynamic content to work with and it’s a case of using expressions to query the body of the outputs of our HTTP steps. Pain, huh!

There’s something else we can do here though, and that is to use the Parse JSON data operation to create dynamic content from our HTTP step outputs!

The flow

So in my flow, I am calling the Microsoft Graph API to get the users in my organisation. Now I want to be able to use dynamic content such as fields about my users in places subsequent in my flow. So… I need to do a Parse JSON!

Before we add the Parse JSON step, run your flow and copy the outputs from the body of your HTTP call step. We’ll need these to generate a schema in our flow on our parse JSON step.

First, add your parse JSON and supply the content with the body from your HTTP request.

Now select the ‘generate from sample’ button and paste in the data you copied from your HTTP call step. Hopefully this isn’t too big… if it is, you might want to do a queried call on your data to return a smaller set of records, and then use this sample.

Note, here, if we have used records that have null values for any properties/columns, and that is the case for every object we’re working with, those fields won’t be present in our JSON output and hence whilst pasting in here to generate a schema, won’t become present in that schema.

So, make sure you’ve got objects with all the fields populated that you’re going to need to make use of later, or at some point.

Anyway… click ‘generate from sample’ and paste in your JSON output.

Then select done and watch it generate your schema! Magic!

Now, if you’ve got fields that sometimes potentially won’t be populated, you might want to remove these from the ‘required’ array that is created in the schema, you might also need to handle this on the object’s columns where supplying say a string with a null value, won’t necessarily make things work! 🙂

To handle those null values against the columns schema, add “null” as a data type to the field.

Now, in your flow, you’ll see the dynamic content for the schema you’ve created to use, and this will pull through the fields from your HTTP request! This works for both single objects and arrays, which will of course create an apply to each if you use the dynamic content unless you’re using things like a first and then querying your Parse JSON, but by that point you may as well query your HTTP step!

Hopefully this post helped you to get a bit of a better understanding of the Parse JSON data operation in Power Automate! If you didn’t understand something, pop a question in the comments below 🙂

Written by
Lewis Baybutt
Microsoft Business Applications MVP • Power Platform Consultant • Blogger • Community Contributor • #CommunityRocks • #SharingIsCaring
Comments
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to LewisDoesDev.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.