[Fixed] The property ‘content’ must be of type JSON in the ‘ParseJson’ action inputs, but was of type ‘application/x-www-form-urlencoded’

I got this error when I tried to Parse JSON when a request is received in Power Automate. I tried many ways to Parse the data but could not succeed. Finally, I got a lead by just randomly doing the try and error method.

To explain the scenario, I was creating a WhatsApp bot using Twilio and Power Automate. Whenever any new message is received, Twilio sends a JSON payload to Power Automate. That payload contains many properties such as from, to, message, etc.

Initially, I tried the action Parse JSON. I got the below error.

BadRequest. The property 'content' must be of type JSON in the 'ParseJson' action inputs, but was of type 'application/x-www-form-urlencoded'.

The reason for the above error is because the content-type is not application/json.

Fix

We will not parse this request. Instead, we will convert all the values [$formdata] to string and then split them by a delimiter that will create an array. In my case, the delimiter is “&”.

Compose 2 contains the below expression –

string(triggerBody())

Initialize variable contains the value as Output from Compose 2. Compose 3 contains the below expression.

split(variables('whatsAppBody'),'&')

That’s it. Now, you have an array with all the $formdata key value pairs. Go ahead and iterate through each element using Apply to Each.

Thank you All!!! Hope you find this useful.

If you liked our content and it was helpful, you can buy us a coffee or a pizza. Thank you so much.


Leave a Reply

Up ↑

%d