HTTP PUT Request Syntax in SuiteScript 2.x
Learn the syntax for HTTP PUT requests in SuiteScript 2.x, including parameters and common errors. TL;DR Opening TL;DR Opening
TL;DR Opening
This article explains how to execute an HTTP PUT request using SuiteScript 2.x, focusing on the syntax, parameters, and potential errors to be aware of in your scripting.
Method Description
The HTTP PUT request method allows you to send data to a specific URL. However, it has some important timeout limitations:
- Connection timeout: 5 seconds
- Data sending timeout: 45 seconds
Note that the PUT request is not functional in unauthenticated client-side contexts, which is crucial for ensuring secure interactions. For further information, refer to the relevant documentation on HTTP requests.
Returns
The PUT request method returns either a http.ClientResponse or http.ServerResponse.
Supported Script Types
- Client Scripts
- Server Scripts
For additional details, check out the SuiteScript 2.x Script Types.
Governance
Using the HTTP PUT method consumes 10 governance units.
Parameters
The options parameter is a JavaScript object containing several key properties:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.body | string Object | Required | The data payload sent with the request. |
options.url | string | Required | The HTTP URL to which the request is sent. |
options.headers | Object | Optional | Custom headers for the request. |
Errors
Here are the common error codes you might encounter when performing a PUT request:
| Error Code | Message | Thrown If |
|---|---|---|
SSS_INVALID_HOST_CERT | An untrusted, unsupported, or invalid certificate was found for this host. | Security negotiation fails or domain issues. |
SSS_INVALID_URL | The URL must be a fully qualified HTTP/HTTPS URL. | Invalid URL specified in options.url. |
SSS_MISSING_REQD_ARGUMENT | Missing a required argument: {param name} | options.body or options.url not specified. |
Example Syntax
Below is a code sample illustrating the syntax used for the HTTP PUT request, although it is not a complete functional example:
1// Add additional code 2...3var headerObj = {4 name: 'Accept-Language',5 value: 'en-us'6};7var response = http.put({8 url: 'http://www.google.com',9 body: 'My PUT Data',10 headers: headerObj11});12...13// Add additional codeRelated Topics
- N/http Module
- SuiteScript 2.x Modules
- SuiteScript 2.x
Key Takeaways
- The HTTP PUT method is critical for sending data to specified URLs.
- Timeout settings can affect request success; understand these limitations.
- Ensure all required parameters are included to avoid common errors.
Frequently Asked Questions (4)
What script types support HTTP PUT requests in SuiteScript 2.x?
What are the required parameters for executing an HTTP PUT request in SuiteScript 2.x?
What happens if I use an invalid URL in an HTTP PUT request?
What are the timeout limitations for HTTP PUT requests in SuiteScript 2.x?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
