Example of a Shell Script that Calls a RESTlet
The following shell script shows you how to send a request to a RESTlet using NLAuth authentication and a Content-Type value of application/json. For information about constructing an NLAuth header, see Using User Credentials for RESTlet Authentication.
#!/bin/sh
#Enter your RESTlet url here.
my_url="https://<accountID>.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=126&deploy=1"
#Enter the body of your request in a file named data.json.
DATA_FILE="@data.json"
CONTENT_FLAG="Content-Type: application/json"
#Update the following line with valid values from your NetSuite account.
AUTH_STRING="Authorization: NLAuth nlauth_account=123456, nlauth_email=jsmith%40ABC.com, nlauth_signature=xxxx"
#Send the request to your RESTlet and capture the response from your RESTlet.
/usr/bin/curl -H "${CONTENT_FLAG}" -H "${AUTH_STRING}" -d "${DATA_FILE}" $my_url > /tmp/restlet_response.txt
Related Topics
- SuiteScript 2.x RESTlet Script and Request Examples
- Example Hello World RESTlet
- Example of a RESTlet that Retrieves, Deletes, Creates, and Upserts a NetSuite Record
- Example of a RESTlet that Adds Multiple Records
- Example of a RESTlet that Manipulates Scheduled Script
- Example of a Client Script that Calls a RESTlet
- Example of a Suitelet that Calls a RESTlet