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
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category