HTTP PUT Request with N/http Module in SuiteScript
HTTP PUT requests in SuiteScript allow data transmission to servers, supporting both client and server scripts.
The HTTP PUT request in SuiteScript enables developers to send data to a specified server URL. This method is key for situations where data needs to be updated rather than just retrieved, allowing for seamless integration and interaction between client-side and server-side applications.
Method Description
The PUT request sends HTTP requests to update resources located at the specified destination URL. Key characteristics include:
- Timeouts: Connection attempts time out after 5 seconds if no response is received. Additionally, if data transfer exceeds 45 seconds, the request will time out.
- Context Requirements: This method cannot function in unauthenticated client-side contexts.
Returns
The response from the PUT method will return either an http.ClientResponse or http.ServerResponse, depending on the context of the script executing the request.
Supported Script Types
The PUT method can be utilized in both client and server scripts within the SuiteScript framework.
Governance
Each PUT request consumes 10 governance units, which should be taken into account to avoid exceeding limits during script execution.
Parameters
When crafting your PUT request, utilize the options parameter as a JavaScript object consisting of:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.body | string | required | The data to be sent in the PUT request. |
options.url | string | required | The target HTTP URL for the request. |
options.headers | Object | optional | Any custom HTTP headers to include. |
Error Handling
Knowing potential error codes can help troubleshoot issues effectively:
- SSS_INVALID_HOST_CERT: Occurs if the certificate for the host cannot be validated. Ensure the domain name is correct and uses valid syntax.
- SSS_INVALID_URL: Triggered by an invalid or improperly formatted URL in the
options.urlparameter. - SSS_MISSING_REQD_ARGUMENT: Indicates required parameters like
options.bodyoroptions.urlare missing.
Syntax Example
Below is a sample code snippet demonstrating the syntax for a basic PUT request:
1// Example of an HTTP PUT request2var headerObj = {3 name: 'Accept-Language',4 value: 'en-us'5};6 7var response = http.put({8 url: 'http://www.example.com/api/update',9 body: 'My PUT Data',10 headers: headerObj11});Remember, this snippet serves as a syntax reference and not a fully functional example. For comprehensive script examples, refer to the N/http Module documentation.
Related Topics
Key Takeaways
- The HTTP PUT method allows data updates to specified server URLs.
- Make sure to provide the required parameters to avoid errors.
- The method adheres to defined timeout policies for connections and data transfer.
- Governance units for each request are set at 10, impacting script usage.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What script types support the HTTP PUT request in the N/http Module?
What are the timeout settings for an HTTP PUT request in SuiteScript?
How many governance units does an HTTP PUT request consume in NetSuite?
What common errors should be anticipated when using the HTTP PUT request?
Was this article helpful?
More in Integration
- Natural Language Queries in NetSuite AI
MCP Standard Tools SuiteApp enables AI-driven data tasks in NetSuite, aligned with role permissions.
- Square Connector Integration in NetSuite 2026.1
Discover the Square Connector for seamless integration with NetSuite 2026.1, synchronizing transactions, orders, and inventory effortlessly.
- SuiteTalk Web Services Updates for NetSuite Integrations
SuiteTalk Web Services adds new Item Supply Plan support, enhancing integrations for efficient data management.
- SuiteTalk Web Services Enhancements in NetSuite
Explore the latest enhancements to SuiteTalk Web Services, improving integration and API functionalities in NetSuite.
Advertising
Reach Integration Professionals
Put your product in front of NetSuite experts who work with Integration every day.
Sponsor This Category