The N/https module enables server-side SuiteScript to make outbound HTTP/HTTPS calls to external APIs and web services. It is the primary module for all REST API integrations in NetSuite.
GET Request
define(["N/https", "N/log"], (https, log) => {
const response = https.get({
url: "https://api.example.com/data",
headers: { "Authorization": "Bearer TOKEN" }
});
log.debug("Response", response.code + ": " + response.body);
return {};
});
POST Request
const response = https.post({
url: "https://api.example.com/orders",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: 123, status: "shipped" })
});
if (response.code === 200) log.audit("Success", response.body);
Key Methods
| Method | Description |
|---|---|
https.get(options) | Send a GET request |
https.post(options) | Send a POST request |
https.put(options) | Send a PUT request |
https.delete(options) | Send a DELETE request |
https.request(options) | Send any HTTP method |