POST form "Unable to parse JSON body"

So I'm trying to fill out a super basic web form with a content type of "Content-Type: application/x-www-form-urlencoded; charset=UTF-8".

The page is hosted at http://www.something.com/contact-us.html, but the form POST request URL is
https://sitesupport-v7.websitetonight.com/api/CustomFormMailer/Submit

When I fill out the form in my browser, the POST data that is sent (the object that is sent?) looks like this:

{"domainName":"something.com","resellerId":1,"elementId":"371086304","subject":"something.com Contact Us: Form Submission","emailHashList":"something@gmail.com","formFields":[{"label":"Name:","value":"myname","type":"input"},{"label":"Email:","value":"myemail@email.com","type":"email"},{"label":"Phone Number","value":"555-555-5555","type":"input"},{"label":"Address","value":"55555 road","type":"input"},{"label":"Message:","value":"order","type":"paragraph"},{"label":"Date and time","value":"04/15/2020 2:30 PM"}],"hostPageUrl":"http%3A%2F%2Fwww.something.com%2Fcontact-us.html"}

The page then shows a message "Thank you for contacting us! We have received your order, we will deliver your order 30 minutes."

... but that message is permanently encoded in the page, and is simply revealed when you post the form.

So I have a function node like this:

var payload = msg.payload;

var data = {"domainName":"something.com","resellerId":1,"elementId":"371086304","subject":"something.com Contact Us: Form Submission","emailHashList":"something@gmail.com","formFields":[{"label":"Name:","value":"myname","type":"input"},{"label":"Email:","value":"myemail@email.com","type":"email"},{"label":"Phone Number","value":"555-555-5555","type":"input"},{"label":"Address","value":"55555 road","type":"input"},{"label":"Message:","value":"order","type":"paragraph"},{"label":"Date and time","value":"04/15/2020 2:30 PM"}],"hostPageUrl":"http%3A%2F%2Fwww.something.com%2Fcontact-us.html"};

msg.headers = {
'content-type':'application/x-www-form-urlencoded'

}

msg.payload = data;
return msg;

and then an HTTP node like this:

The msg.payload object of my flow looks the same as the data above. But when I submit, I receive "Unable to parse JSON body".

Is my flow expecting a JSON response that it isn't receiving?
Is my flow sending JSON when it should be a string?
Is the error message sent by the server I am contacting?
Is it working silently?

Unfortunately I don't have a way to test if its working without putting in an order for some beers lol.

The end goal is to ask google to order me some beer.

Have you tried content type

application/json

No I have not, only because my browser REQ shows as application/x-www-form-urlencoded when it submits the form.

I guess you're thinking, the server expected JSON and is complaining that I sent it as urlencoded?

I tried. I got back a reply:

status 200 is good... almost feels like it might have worked?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.