Although it could depend on the ServiceNow release my Orchestrator action with JavaScript to retrieve the oauth2 is a bit different.
I'm actually adding the content to the URL :
querystring = '/oauth_token.do?' + content
Then i also pass the OAuth 2.0 with empty token in the authorization - if not you may see an access denied in the return,, so :
var auth = RESTAuthenticationManager.createAuthentication('OAuth 2.0', [' ', 'Authorization header'])
transientHost.authentication = auth
then i just do a createrequest with a POST and querystring and the content -> not sure the content is needed since it's a urlencoded contentType ...
Original Message:
Sent: May 07, 2023 12:31 PM
From: eoinbyrne
Subject: vmWare vRO & serviceNow APi's with OAUth Get Token
Hi,
Looking at the image there where you define the content, it seems like you have literal space characters embedded & if I understand correctly these will cause a problem for the server

I've put the red boxes over the areas where you have those spaces. If you remove those and try that again?
Also, what are the values of response.statusCode and response.content when you make this request?