我正在编写一个脚本,想要从 URL 请求中读取内容。
header['Content-Type']='text/xml'; var apiURL='https://system.na2.netsuite.com/app/setup/upload/csv/csvstatus.nl?XML=T'; var response=https.get({ url:apiURL, headers:header, }); var newSFID=response.body; log.debug("XML",a);
但它不会读取内容,而是将登录页面并登录初始登录页面。知道如何阅读吗?
最佳答案
这是完全可行的。问题是您没有提供任何授权。如果您不想获得登录页面,则必须提供授权 header 。我已经更新了下面的代码(并且经过测试没有任何问题,除了我不相信该页面会显示为 XML?)。只需添加您正确的身份验证信息即可。
require(['N/record','N/https'],function(record,https){
function test(){
var header=[];
header['Content-Type']='text/xml';
header['Authorization']='NLAuth nlauth_account=NETSUITEACCOUNT,nlauth_email=LOGINEMAIL,nlauth_signature="LOGINPASSWORD",nlauth_role=3'
var apiURL='https://system.na2.netsuite.com/app/setup/upload/csv/csvstatus.nl?xml=T';
var response=https.get({
url:apiURL,
headers:header
});
log.debug('response.body',JSON.stringify(response.body));
}
test();
});
关于Netsuite 内部 URL 内容调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46911097/