简体   繁体   中英

Netsuite SuiteScript RESTlet get URL information

Using this example RESTlet code below, is there any way to get information about the HTTP request's calling URL? I know my deployment URL is this (shown below), but how can I get that information in my get, delete, post, or put functions?

https://123123-abc.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=123&deploy=1

I call the above URL in Postman or other client apps and I pass in header info and a JSON payload. I only have access to the JSON payload inside my RESTlet code below. I would like to get access to the URL that was called.

/**
*@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
    };
}); 

I am answering my own question. This is one way I found to get the URL navigation paths within Netsuite. Using the N/url module provided by Netsuite, I can do the following. If there are better ways, let me know.

require(['N/url'], function(url) { 
    var host = url.resolveDomain({
      hostType: url.HostType.APPLICATION
    });
    console.log(host)
    // result = 123123-abc.app.netsuite.com
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM