Anyone know why when I perform an <https.post> fro...
# general
n
Anyone know why when I perform an https.post from my 2.0 suitescript it transforms the body from an object like
Copy code
{ foo:"bar", hello: "goodbye" }
into
Copy code
foo=bar&hello=goodbye
? And how do I avoid this? I just want the body object to remain a standard JSON object at the destination...
r
Hi Nate, you may need to specify the content type as application/json in the header
I'll confirm
Yeah, try putting "Content-Type: 'application/json'" in the header object
j
do JSON.stringify on your object
Copy code
<http://https.post|https.post>({
  url: 'dest',
  body: JSON.stringify({ foo: 'bar', hello: 'goodbye' })
});
If you don't JSON.stringify it serializes it like a regular html form i.e. application/x-www-form-urlencoded
n
I am specifying application/JSON...
I'll try stringify
thank you!!
b
I would actually say you need to do both. Passing in an object is telling NetSuite you want to pass form data
which is why you got form data
you want to specify a content type of json since thats just nice to your server
j
⬆️