I am able to submit a https post for the login int...
# suitescript
k
I am able to submit a https post for the login into an api. I am not trying to submit an object to the third party software. The only error I recieve is "unexpected Error"
c
You’re passing an object to the body, so might want to read this (specifically about headers): https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4418229131.html#subsect_1558529145
(I am not saying it is the problem, I am suggesting you read it)
What’s the host on the other end expecting to receive by the way? JSON?
k
it is sent as a json object
n
try to stringify your body object before sending it
k
When i added JSON.stringifiy(bodyOBJ) i got a 401 "{"Message":"Authorization has been denied for this request."}" and I know the bearertoken is recent. Should i add headerOBJ = {
name: "Authorization", value: bearertoken
to get it to authenicate
c
The format is usually: Authorization: Bearer <token>
🙌 1
You said you have it working in postman, so you can verify by looking at the headers for your successful request
b
your invalid login request is closer to correct than the unexpected error
an object used as the body is form encoded first, and netsuite does not know how to form encode empty arrays or arrays of objects
in general, arrays dont work with form encoding
general recommendation if you have a working request is to use an echo service like httpbin or postman echo to compare both the working request and the request from netsuite
🙌 1