如何从外部调用netsuite restlet?

时间:2016-07-15 11:40:42

标签: web-services google-apps-script netsuite restlet suitescript

我尝试过谷歌脚本但收到错误:

  

“USER_ERROR   错误消息:没有授权标头'

var url = 'https://debugger.na1.netsuite.com/app/site/hosting/restlet.nl?script=107&deploy=1';

var header = {
    contentType: 'application/json',
    Authorization: 'NLAuth nlauth_account=TSTDRVXXXXX,    nlauth_email=xxx@xxx.com, nlauth_signature=XXXXXXX, nlauth_role=3',
    method: 'GET',
    muteHttpExceptions: true
  };

  var response = UrlFetchApp.fetch(url, header);

1 个答案:

答案 0 :(得分:2)

您应该查看UrlFetchApp的文档。您已折叠标题和可选参数。设置应该更像:

var params = {
    contentType: 'application/json',
    headers:{Authorization: 'NLAuth nlauth_account=TSTDRVXXXXX, nlauth_email=xxx@xxx.com, nlauth_signature=XXXXXXX,     nlauth_role=3'},
    method: 'GET',
    muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, params);