Hi, has anyone run into a issue where a JSON body ...
# suitescript
g
Hi, has anyone run into a issue where a JSON body (contains key: array []) is being POST'ed to an external service, in which the array is completely dropped from the request?
b
use an echo service like http://httpbin.org/ to see what your body looks like
g
Oh cool thanks, will look at this now
b
if this is your first time working with N/https and json, the common mistake is that there is different behaviors between a string body and an object body
objects are encoded as a form post
g
Oh right! So I should use the form Content-Type for this, rather then application/json?
You're right, this is my first time 🙂
b
you usually dont have a choice, the service you are working with determines the content types it recognizes
g
Cheers, will check this out, and confirm what the endpoint expects 🙂
Though, I believe the endpoints only accepts JSON, or perhaps GraphQL too (I haven't touched GraphQL before hehe)
b
if it expects a form post, then use an object
anything else you need to use a string as the body
g
Oh awesome, thank you