如何使用nlapiRequestURL
向服務發出請求?我的下面的嘗試失敗,錯誤:UNEXPECTED_ERROR
(從NetSuites腳本執行日誌輸出)。使用nlapiRequestURL向服務發出請求
我的服務被設置爲不登錄時運行和正常工作時,我直接通過使用其URL瀏覽器訪問它。它只是通過nlapiRequestURL
這是失敗的要求。
任何想法可能會出錯?
// This code executes in Account.Model.js (register function)
// I am using my own netsuite user credential here
var cred = {
email: "MY_NETSUITE_EMAIL"
, account: "EXXXXX" // My account id
, role: "3" // Administrator
, password: "MY_NETSUITE_PASSWORD"
};
var headers = {"User-Agent-x": "SuiteScript-Call",
"Authorization": "NLAuth nlauth_account=" + cred.account + ", nlauth_email=" + cred.email +
", nlauth_signature= " + cred.password + ", nlauth_role=" + cred.role,
"Content-Type": "application/json"};
var payload = {
type: 'is_email_valid'
, email: '[email protected]'
};
// A raw request to the service works fine:
// http://mywebsite.com/services/foo.ss?type=is_email_valid&[email protected]
// Error occurs on next line
var response = nlapiRequestURL(url, payload, headers);
爲什麼您將Netsuite授權標頭傳遞給您的外部服務? – michoel
正在調用RESTlet嗎? – pipechang
我沒有看到你的代碼中你指定了什麼網址 - 就像在'var url ='...我想你只是沒有顯示該部分,但值得檢查我猜 – Krypton