Identifying a RESTlet in a Call

Before you call a RESTlet, you’ll need to know how to identify it, which depends on whether you’re calling it from inside or outside NetSuite. Usually, you'll use values from the script deployment record, and sometimes the script record ID too.

Internal Versus External Calls

The script and deployment records have everything you need to identify a RESTlet. The exact values to use depend on where the call comes from.

Script and Script deployment records for a RESTlet with ID and URL fields called out.

Source of the Call

Identify the RESTlet with:

An external client

A full URL, similar to the one shown on the script deployment record, in the External URL field (callout 4). For details, see Dynamically Generating a Full URL.

A client SuiteScript with an active session in the same NetSuite account where the RESTlet is deployed

Either of the following:

A server SuiteScript in the same NetSuite account where the RESTlet is deployed

A full URL, similar to the one shown on the script deployment record, in the External URL field callout (4). This URL must be dynamically generated, in one of the following ways:

  • By using the REST roles service. For details, see The REST Roles Service.

  • A URL generated by using the N/url module. To generate the URL this way, you need the script ID, which is viewable on the script record in the ID field (callout 1), in combination with the deployment ID, which is viewable on the script deployment record, in its ID field (callout 2). For an example, see Example of a Suitelet that Calls a RESTlet.

A server SuiteScript in a different NetSuite account from where the RESTlet is deployed

A full URL, similar to the one shown on the script deployment record, in the External URL field (callout 4). This URL must be dynamically generated by using the REST roles service. For details, see Dynamically Generating a Full URL.

Note:

If you are calling a RESTlet by using the delete or get method, you must extend the URL to include any input data that is required by the RESTlet’s logic. For details, see Selecting an HTTP/HTTPS Method for Calling a RESTlet.

Dynamically Generating a Full URL

When you save the deployment record, NetSuite gives you the full URL in the External URL field. But don’t hard-code this URL—add logic to build the RESTlet domain dynamically instead.

You can do this in a couple of ways:

Note:

Since 2017.2, you can use account-specific domains for RESTlets at .restlets.api.netsuite.com. The old data center-specific domains still work, too. For more info, see URLs for Account-Specific Domains.

Related Topics

General Notices