I am not getting valid json response while calling 3rd party REST GET URL from netsuite . The 3rd party api is using oAuth2 , so i am passing the bearer token like this in the UserEvent Script . Can someone please tell what is wrong with this code .Below is the code snippet.
var sURL = "REST URL";
var header = { "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wYW55X2lkIjoiYXBpdXNlck1ITVUiLCJ1c2VyX25hbWUiOiJhcGl1c2VyIiwic2NvcGUiOlsiYWNjdF9wYXlhYmxlIl0sImV4cCI6MTU0MzcxOTY3NCwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6IjU4MjA2YTRkLTRhYTgtNDNjNy1iZTY2LWM2YTQ1NTg0YTY2ZSIsImNsaWVudF9pZCI6Im5ldHN1aXRlLWNsaWVudCJ9.dPuwIpzZW3VrhkJnF_HaaNe8t4AMQ84UgMY5ZOK6j7g",
"Content-Length": "0",
"Content-Type": "application/json" };
var request = https.get({
url: sURL,
headers: header
});
log.debug('req',request);
Getting below output in debugger:
{"type":"http.ClientResponse","code":406,"headers":{"X-Content-Type-Options":"nosniff","Pragma":"no-cache","Date":"Sat, 01 Dec 2018 23:46:46 GMT","Via":"1.1 mono00001.svale.netledger.com","X-Frame-Options":"DENY","Cache-Control":"no-cache, no-store, max-age=0, must-revalidate","Set-Cookie":"JSESSIONID=4E42866C0A8D2D8504581B74C8D6FC1C; Path=/; HttpOnly","Expires":"0","Content-Length":"806","X-XSS-Protection":"1; mode=block","Content-Language":"en","Content-Type":"text/html;charset=utf-8"},"body":"HTTP Status 406 – Not Acceptableh1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}
NetSuite does not support oauth2.