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 đ