![](/img/trans.png)
[英]How to get bundle information through RESTlet script in Netsuite suitescript 2.0?
[英]Netsuite SuiteScript RESTlet get URL information
使用下面的示例 RESTlet 代碼,有什么方法可以獲取有關 HTTP 請求的調用 URL 的信息? 我知道我的部署 URL 是這樣的(如下所示),但是如何在我的 get、delete、post 或 put 函數中獲取該信息?
https://123123-abc.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=123&deploy=1
我在 Postman 或其他客戶端應用程序中調用上述 URL,並傳入標頭信息和 JSON 有效負載。 我只能訪問下面我的 RESTlet 代碼中的 JSON 有效負載。 我想訪問被調用的 URL。
/**
*@NApiVersion 2.x
*@NScriptType Restlet
*/
define(['N/record', 'N/error'],
function(record, error) {
// Get a standard NetSuite record
function _get(context) {
// Is there a way to get information about the request URL at this point?
return JSON.stringify(record.load({
type: context.recordtype,
id: context.id
}));
}
return {
get: _get,
delete: _delete, // not shown
post: post, // not shown
put: put, // not shown
};
});
我正在回答我自己的問題。 這是我發現在 Netsuite 中獲取 URL 導航路徑的一種方法。 使用 Netsuite 提供的 N/url 模塊,我可以做到以下幾點。 如果有更好的方法,請告訴我。
require(['N/url'], function(url) {
var host = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
console.log(host)
// result = 123123-abc.app.netsuite.com
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.