使用令牌从 netsuite 调用外部 REST URL 时出错
Error while calling External REST URL from netsuite using token
我在从 netsuite 调用第 3 方 REST GET URL 时没有得到有效的 json 响应。第 3 方 api 正在使用 oAuth2 ,所以我在 UserEvent 脚本中像这样传递不记名令牌。谁能告诉我这段代码有什么问题。下面是代码片段。
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);
调试器中的输出低于:
{"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;模式=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;}
HTTP Status 406 – Not Acceptable
"
}
NetSuite 不支持 oauth2。
我遇到了同样的问题,但这 header 解决了问题
var header = {"Accept": "*/*",
"Content-Type":"application/json",
"Authorization": 访问令牌
}
我在从 netsuite 调用第 3 方 REST GET URL 时没有得到有效的 json 响应。第 3 方 api 正在使用 oAuth2 ,所以我在 UserEvent 脚本中像这样传递不记名令牌。谁能告诉我这段代码有什么问题。下面是代码片段。
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);
调试器中的输出低于:
{"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;模式=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;}
HTTP Status 406 – Not Acceptable
" }NetSuite 不支持 oauth2。
我遇到了同样的问题,但这 header 解决了问题
var header = {"Accept": "*/*", "Content-Type":"application/json", "Authorization": 访问令牌 }