Hi everyone! Does anyone here have experience send...
# suitescript
r
Hi everyone! Does anyone here have experience sending OAuth2 token requests from NetSuite to an external server? Using https.request in SS2.0 but I'm not sure if I've formatted everything correctly. SuiteAnswers doesn't provide much information on this particular scenario
b
unless you are trying to get a new access token, it should be a fairly simple putting the bearer token in the authorization header
the more unusual is in the request body as a form parameter
r
I'm trying to get a new access token from AWS Cognito
And the request body is x-www-form-urlencoded
b
which grant type does it use?
r
client_credentials
I put the base64-encoded client_id:client_secret in the Authorization header
b
what does the code look like
r
var requestHeader = {     'Authorization':'Basic [Base64-encoded string]',     'Content-Type':'application/x-www-form-urlencoded',     'Accept':'application/json' }; var requestBody = {     'grant_type':'client_credentials' }; var response = https.request({ method : https.Method.POST, url : https://myurl.com, header : requestHeader, body : requestBody });
b
probably safer to use netsuite's built in support
dont set the content type
r
Yeah I've tried that, unfortunately. Still get a 405
b
id try tossing the the accept header
and potentially add the scope and client_id parameters
r
The strange thing is that those parameters aren't needed when sending from Postman or ARC. Just from NetSuite. So I was more wondering if it's a known issue that NetSuite manipulates the request in some way before sending it out
At this point I might just create a support ticket though. Thanks for your help!
b
you can try posting to an echo service like httpbin.org
to see what your request looks like
r
Good to know that that exists!
I was struggling through trying to figure out apiary
Again, appreciate the help