cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mick282
Level: Powered On

application/x-www-form-urlencoded content type error using when a HTTP request is received

Hi

 

I'm using a webhook created by Unbounce forms. The problem with the webhook is that it sends the payload with a content type of application/x-www-form-urlencoded. I'm now getting this weird error :

 

 

{
  "error": {
    "code": "InvalidRequestContent",
    "message": "The input body for trigger 'manual' of type 'Request' must be of type JSON, but was of type 'application/x-www-form-urlencoded'."
  }
}

 

 

A sample payload of what is submitted is below:

 

 

{
  "$content-type": "application/x-www-form-urlencoded",
  "$content": "<a base 64 encoded content>",
  "$formdata": [
    {
      "key": "page_url",
      "value": "url of the form"
    },
    {
      "key": "page_name",
      "value": "name of the page"
    },
    {
      "key": "page_id",
      "value": "id of the page"
    },
    {
      "key": "variant",
      "value": "a"
    },
    {
      "key": "data.json",
      "value": "The JSON object containing the field values of the form"
    },
    {
      "key": "data.xml",
      "value": "XML version"
    }
  ]
}

 

 

When I initially setup the HTTP request is received trigger it seems to take the webhook and schema correctly but as I'm adding items to it, it throws the error that it needs fixing. A snippet of the whole flow is below:

 

image.png

 

What I first do is select the data.json value in the array and parse JSON

 

image.png

 

The expression in the Content field is:

 

triggerBody()?['$formdata'][4]

 

Basically I'm selecting the data.json value in the formdata array.

 

I then parse the full JSON value.

image.png

 

The expression in the content is:

 

json(body('Parse_data.json')?['value'])

 

 

It seems to submit and flow correctly during an initial test of the webhook and submission of the unbounce form but any future submissions throws the error:

 

 

{
  "error": {
    "code": "InvalidRequestContent",
    "message": "The input body for trigger 'manual' of type 'Request' must be of type JSON, but was of type 'application/x-www-form-urlencoded'."
  }
}

 

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: application/x-www-form-urlencoded content type error using when a HTTP request is received

 

Hi @Mick282 ,

 

Do you mean that the body output by the trigger is the sample you provided?

Then this part of the content cannot be used in Parse JSON, because its type is clearly application / x-www-form-urlencoded and not JSON.

You need to extract $ formdata first and then parse it.

Please check the attachment and import it as a new Flow.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: application/x-www-form-urlencoded content type error using when a HTTP request is received

 

Hi @Mick282 ,

 

Do you mean that the body output by the trigger is the sample you provided?

Then this part of the content cannot be used in Parse JSON, because its type is clearly application / x-www-form-urlencoded and not JSON.

You need to extract $ formdata first and then parse it.

Please check the attachment and import it as a new Flow.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Mick282
Level: Powered On

Re: application/x-www-form-urlencoded content type error using when a HTTP request is received

Hi @v-bacao-msft ,

 

Thanks for sending through the zip file. Quick question. If I use the apply to each, how do I extract the value from key : data.json?

 

Basically that's the only section of the formdata array that I'm interested in.

 

It seems to be caused by an issue with the trigger itself which is the When a HTTP request is received.

 

It won't even register the flow run when I do a test submission

Community Support Team
Community Support Team

Re: application/x-www-form-urlencoded content type error using when a HTTP request is received

 

Hi @Mick282 ,

 

If you created the Flow using the .zip file I provided, you need to replace the trigger with When a HTTP request is received.

And configure the parameters included in the previous Flow in the trigger.

Then configure the trigger body in Compose. Here I guess that the body output by the trigger is the sample you provided, so a specific method is provided.

 

Regarding extract the value from key: data.json, I'm afraid I don't understand what you mean. Parse JSON has parsed out the data contained in $formdata, you only need to use Dynamic content to get the attribute value directly.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,406)