HTTP Request Parameters in SuiteScript for Integration
Learn about HTTP request parameters in SuiteScript, including methods, headers, and error handling for effective integrations.
Starting in SuiteScript, developers can utilize the http.request() function to send HTTP requests efficiently. Understanding the parameters involved and their configurations is essential to ensuring that these requests are properly formulated and that pertinent responses are appropriately handled.
Method Description
This function sends an HTTP request and supports both client and server scripts. Be mindful that connections will time out if they exceed certain thresholds: if it takes longer than 5 seconds to connect to the server, the connection will timeout; sending the request payload must be completed within 45 seconds. Note that this method cannot be executed in unauthenticated client-side contexts.
Returns
On execution, this method returns either http.ClientResponse or http.ServerResponse based on the script context. This flexibility allows developers to handle responses appropriately based on the deployment context.
Supported Script Types
- Client scripts
- Server scripts
Governance
Each call to this method consumes 10 governance units.
Parameters
The options parameter is crucial for the configuration of the HTTP request. Below is a breakdown of its fields:
| Parameter | Type | Required/Optional | Description |
|---|---|---|---|
options.method | enum | Required | The HTTP method for the request, set using http.Method. |
options.url | string | Required | The target HTTP URL for the request. |
options.body | string | Object | Optional |
options.headers | Object | Optional | HTTP headers for the request. More information can be found in the HTTP Header Information. |
Error Handling
When working with http.request(), it is important to handle potential errors. Here are some common errors you may encounter:
| Error Code | Message | Thrown If |
|---|---|---|
SSS_INVALID_HOST_CERT | An untrusted, unsupported, or invalid certificate is detected. | This occurs when the client and server cannot agree on the security level, or the URL is invalid. |
SSS_INVALID_URL | The URL must be a fully qualified HTTP/HTTPS URL. | The specified URL in options.url is incorrect. |
SSS_MISSING_REQD_ARGUMENT | Missing a required argument: {param name} | This happens when either options.method or options.url is not specified during the request setup. |
Syntax Example
Here is an example of how to use the http.request() method:
1var headerObj = {2 name: 'Accept-Language',3 value: 'en-us'4};5var response = http.request({6 method: http.Method.GET,7 url: 'http://www.example.com',8 body: 'My REQUEST Data',9 headers: headerObj10});This example showcases how to set HTTP headers and send a GET request to a specified URL. Ensure that you replace 'http://www.example.com' with your target URL.
Key Takeaways
- The
http.request()method is pivotal for sending HTTP requests from SuiteScript. - Understanding the required parameters and their types is crucial for successful requests.
- Proper error handling is necessary to manage issues related to invalid URLs and certificates.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
What HTTP methods are supported by the new HTTP request parameters in SuiteScript 2026.1?
How can developers handle errors related to HTTP requests in SuiteScript?
Are there any governance limitations associated with making HTTP requests in NetSuite SuiteScript?
What happens if the connection or request takes too long in SuiteScript 2026.1?
Weekly Update History (1)
Added information to the following methods and modules to clarify that they are not supported in unauthenticated client-side contexts N/http methods: http.request(options) http.get(options) http.post(options) http.put(options) http.delete(options) N/https methods: https.request(options) https.get(options) https.post(options) https.put(options) https.delete(options) N/url methods: url.resolveRecord(options) url.resolveScript(options) url.resolveTaskLink(options) N/query Module N/search Module N/dataset Module N/workbook Module
View Oracle DocsWas this article helpful?
More in SuiteScript
- 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.
- 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.
- Attach and Detach Operations in NetSuite 2026.1
Attach and detach operations for record relationships in NetSuite enhance data management and connectivity.
- Create-Form Operation in NetSuite 2026.1 REST Web Services
Create-form operation in NetSuite 2026.1 APIs streamlines record creation and enhances efficiency.
