Deploying a RESTlet
Before you can use a RESTlet, you must follow the same guidelines as you would with other script types. At a high level, you must make sure the script is formatted properly and you must create a script record.
For a RESTlet to be properly formatted, all of the following must be true:
-
The script must have the correct SuiteScript 2.x structure. For example, the script must include at least one entry point and corresponding entry point function suitable for the RESTlet script type. For more information about how to structure a SuiteScript 2.x script, see Required Structure for Entry Point Scripts. Note that the entry points you use will determine how the RESTlet can be called. For more information about the RESTlet entry points, see SuiteScript 2.x RESTlet Script Entry Points.
-
The script must use the required JSDoc tags. At a minimum, the @NScriptType must be
RESTlet
(Restlet
orrestlet
; these values are not case–sensitive). For more information about required JSDoc tags, see Required JSDoc Tags for Entry Point Scripts.
Before you can call a RESTlet, you must upload your script file to your File Cabinet and create a script record and a script deployment record for it. For help creating script records and script deployment records, see SuiteScript 2.x Record-Level Script Deployments.
When creating these records for a RESTlet, be aware of the following:
-
You should enter meaningful data in the script record’s ID field and the script deployment record’s ID field. When you save the records, the system creates IDs that include the text you entered. One possible use of these IDS is to identify the RESTlet when calling it from another SuiteScript. For this reason, it may be helpful to have created meaningful ID strings.
-
Unlike other script types, you do not deploy a RESTlet for any particular record type. RESTlets are available independent of any particular record type or record instance.
-
The script deployment record includes a field called Status, which has possible values of Released and Testing. Before you can call the RESTlet from an external source, the Status field must be set to Released.
-
When you save a script deployment record for a RESTlet, the system automatically generates a partial and full URL that you can use to call the RESTlet, as shown in the following image.
However, if you are calling the RESTlet from within an integration and you want to use the full URL, you must include logic that dynamically discovers the RESTlet domain. For more information, see Identifying a RESTlet in a Call.