N/http and N/https Support PATCH Method in NetSuite
N/http and N/https now support the PATCH method for API calls, enhancing integration in NetSuite.
TL;DR Opening
N/http and N/https modules in NetSuite now support the PATCH method, enabling developers to perform updates directly via API calls. This enhancement is crucial for improving integration capabilities within applications, making it easier to modify existing resources.
What Changed?
Starting in the latest update, the method enumeration in both N/http and N/https modules includes the PATCH method. This addition allows users to make more granular updates to resources via external calls and Suitelet calls using the following functions:
http.request(options)https.request(options)https.requestSuitelet(options)clientCertificate.request(options)
How to Use PATCH Method?
You can pass either http.Method.PATCH or https.Method.PATCH in any parameter that requires a method value. However, if a particular API endpoint does not permit the PATCH method, users will receive an HTTP 405 error indicating that the method is not allowed.
Important Considerations
-
Ensure that the
optionsparameter (a JavaScript object) correctly contains the required fields to use the PATCH method:options.method: required, must be set using eitherhttp.Method.PATCHorhttps.Method.PATCH.options.url: required, this should be the URL to which the request is made.options.body: optional, applicable only for PATCH requests alongside PUT and POST.options.headers: optional, for specifying additional HTTP/S headers.
-
Timeouts: If a connection to the destination server takes longer than 5 seconds, a timeout will occur. Similarly, if the request payload takes longer than 45 seconds, the request will timeout. This means that good error handling is essential to manage these scenarios appropriately.
Example Usage
Here is a simple example of using the PATCH method with the N/http module:
1"text-purple-400">var http = "text-purple-400">require('N/http');2 3"text-purple-400">var options = {4 method: http.Method.PATCH,5 url: 'https://api.example.com/resource/123',6 body: JSON.stringify({ key: 'value' }),7 headers: {8 'Content-Type': 'application/json'9 }10};11 12"text-purple-400">var response = http.request(options);This example demonstrates how to send a PATCH request to update a specific resource identified by its ID. Always check the responses to ensure validation and handle any errors that may occur.
Who This Affects
- Developers: Anyone developing or maintaining integrations with external services using the N/http or N/https modules will benefit from this feature.
- Administrators: Those responsible for system integrations may need to review changes in API usage.
Key Takeaways
- The PATCH method is now available in N/http and N/https modules.
- It allows for partial updates to resources via API calls.
- Ensure correct error handling for HTTP 405 responses when using PATCH.
- Understand the timeout limits on request connections and payloads for efficient API interaction. Source: This article is based on Oracle's official NetSuite documentation.
Was this article helpful?
More in Integration
- Square Connector Integration in NetSuite 2026.1
Discover the Square Connector for seamless integration with NetSuite 2026.1, synchronizing transactions, orders, and inventory effortlessly.
- AI Connector Service: Natural Language Queries in NetSuite 2026.1
In 2026.1, the AI Connector Service allows natural language queries for retrieving data and managing NetSuite records directly through AI clients.
- NetSuite AI Connector Service Enhancements in Version 1.0.6
Explore enhancements in NetSuite AI Connector Service version 1.0.6, including new tools and updated functionalities for improved data interaction.
- Narrative Insights in NetSuite: Latest AI Features 2023
Explore NetSuite's latest AI advancements in recent release notes.