Selecting an HTTP/HTTPS Method for Calling a RESTlet

When you call a RESTlet, you can use one of four HTTP/HTTPS methods: delete, get, post, or put. Use the N/https module to connect SuiteScript scripts, RESTlets, and SuiteTalk REST endpoints without needing to reauthenticate. Use https.requestRestlet(options) or https.requestSuiteTalkRest(options) to send HTTPS requests to a RESTlet or REST endpoint.

When you call a RESTlet, keep these things in mind:

A Call’s Method Must Match an Entry Point

Each HTTP/HTTPS method (delete, get, post, put) matches a RESTlet entry point. Your call must use the method that’s defined in the RESTlet’s interface, or it won’t work.

Here’s an example: A Suitelet uses the https.get method to call a RESTlet. Since the RESTlet’s interface includes a get entry point, the call works.

An example call to match the entry point of a Suitelet. The call's method must match then entry point.

HTTP/HTTPS Methods are Dependent on RESTlet Script Entry Points

A RESTlet doesn’t always have to follow the normal rules for HTTP/HTTPS methods. For example, you could write a get entry point that accepts data to post (though that’s not best practice).

The following http methods are supported for RESTlets: delete, get, post, and put. These methods are defined at the following link: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html.

Keep in mind, a RESTlet’s behavior depends on how you write the script and might not match the intended behavior of the HTTP method. For example, you could have a get entry point that creates data or a post entry point that doesn’t require input—but you should not do that

Input Data Is Handled Differently by Different HTTP Methods

RESTlet entry points handle input parameters differently, depending on which one you use.

How you pass input to a RESTlet depends on the HTTP method:

HTTPS Methods for Secure Communication Between SuiteScripts and REST Endpoints

SuiteScript scripts, RESTlets, and SuiteTalk REST endpoints now share authentication from an existing session. Before, you had to log in again if you called one script from another. Now, the N/https methods let you skip reauthentication:

This new method means you don’t have to make a Suitelet available without login or set it to execute as Administrator just to pass information between SuiteScripts, RESTlets, or REST APIs.

Note:

These methods are just for calling RESTlets within NetSuite, not from outside applications.

Related Topics

General Notices