HTTP PUT Request Syntax in SuiteScript 2.0
Learn the syntax for making asynchronous HTTP PUT requests in SuiteScript 2.0, including parameters and error handling.
The HTTP PUT request method in SuiteScript 2.0 allows developers to send asynchronous HTTP requests with the ability to handle responses using promises. Understanding this syntax is essential for developers looking to integrate external APIs into their NetSuite applications effectively.
What is the HTTP PUT Request?
The HTTP PUT method is used to send updated information to a specified resource. In SuiteScript, this method can be used to transmit data to remote servers reliably. Here are key components you need to know:
Method Description
- Function: Sends an HTTP PUT request asynchronously.
- Returns: A
Promise Objectrepresenting the outcome of the request. - Governance: This method consumes 10 units of governance per call.
- Module: This function is part of the
N/http Module. - Supported Script Types: Both client-side and server-side scripts can utilize this method.
Parameters
The options parameter must be provided as a JavaScript object. Below are the key parameters you can use:
| Parameter | Type | Required | Description |
|---|---|---|---|
options.body | string or Object | Required | The PUT data to be sent. |
options.url | string | Required | The HTTP URL being requested. |
options.headers | Object | Optional | The HTTP headers to include with the request. |
Example Syntax
The following code sample demonstrates how to structure an HTTP PUT request. Note that this example is focused on syntax and not a complete functional application.
1// Additional code ...2var headerObj = {3 name: 'Accept-Language',4 value: 'en-us'5};6http.put.promise({7 url: 'http://www.example.com',8 body: 'My PUT Data',9 headers: headerObj10})11 .then(function(response) {12 log.debug({13 title: 'Response',14 details: response15 });16 })17 .catch(function onRejected(reason) {18 log.debug({19 title: 'Invalid Request:',20 details: reason21 });22 });23// Additional code ...Error Handling
When using the HTTP PUT method, be aware of potential errors:
- SSS_INVALID_HOST_CERT: Thrown for untrusted or invalid certificate.
- SSS_INVALID_URL: Occurs if a malformed URL is specified.
By understanding the syntax and mechanics of the HTTP PUT request in SuiteScript 2.0, developers can effectively manage data flows between NetSuite and external web services, enhancing application integration capabilities.
Key Considerations
- Ensure that the connection times out appropriately (after 5 seconds to connect, and 45 seconds to send).
- This method is not suitable for unauthenticated client-side contexts.
Key Takeaways
- HTTP PUT requests allow asynchronous updates to resources in SuiteScript.
- Utilize promises for effective response handling.
- Important to manage errors and understand timeout limitations.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
Does the HTTP PUT request method in SuiteScript 2.0 support both client-side and server-side scripts?
What happens if an invalid URL is specified in the HTTP PUT request?
How many governance units does an HTTP PUT request consume in SuiteScript 2.0?
What should be done to handle untrusted or invalid certificates in HTTP PUT requests?
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