HTTP Request Parameters in SuiteScript for NetSuite
Learn about the parameters for HTTP requests in SuiteScript, including methods, URLs, and body content management.
The http.request method in SuiteScript enables developers to send HTTP requests. Understanding its parameters is essential for effective integration and interaction with external APIs.
How Does the HTTP Request Work?
The http.request method sends an HTTP request and the connection timeout settings are critical to note:
- The connection will time out if it exceeds 5 seconds.
- Request payloads must be completed within 45 seconds.
Keep in mind, this method is not usable in unauthenticated client-side contexts.
What Are the Supported Script Types?
This method can be utilized in both client and server scripts, making it versatile for different script types in the SuiteScript 2.x environment.
What Are the Governance Limits?
Each HTTP request operation consumes 10 governance units.
Parameters
The options parameter is required and must be a JavaScript object, containing the following fields:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.method | enum | Required | The HTTP request method, set using http.Method (e.g., GET, POST). |
options.url | string | Required | The fully qualified HTTP/HTTPS URL being requested. |
options.body | `string | Object` | Optional |
options.headers | Object | Optional | The HTTP headers to include with the request. |
What Errors Might Occur?
Several error codes can be returned to help diagnose issues when a request fails:
SSS_INVALID_HOST_CERT: A certificate issue is detected.SSS_INVALID_URL: The specified URL is not fully qualified.SSS_MISSING_REQD_ARGUMENT: Required parameters (options.methodoroptions.url) are missing.
Example Syntax
Here’s a basic example demonstrating how to structure an HTTP request using SuiteScript:
1var headerObj = {2 name: 'Accept-Language',3 value: 'en-us'4};5var response = http.request({6 method: http.Method.GET,7 url: 'http://www.google.com',8 body: 'My REQUEST Data',9 headers: headerObj10});This syntax allows for various configurations tailored to specific use cases by modifying the parameters provided.
Key Takeaways
- The HTTP request method requires specific parameters for functionality.
- Proper error handling is crucial for identifying issues related to requests.
- Governance units consumed during requests must be considered to avoid exceeding limits.
Frequently Asked Questions (4)
Does the N/http module support both client-side and server-side scripts?
What happens if my HTTP request takes longer than the specified timeouts?
Are there specific error codes I should be aware of when using the N/http module?
Do I need to handle errors when making HTTP requests with the N/http module?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- 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.
- 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.
