HTTP Request Parameters in SuiteScript for NetSuite

Learn about the parameters for HTTP requests in SuiteScript, including methods, URLs, and body content management.

·2 min read·5 views·View Oracle Docs

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:

ParameterTypeRequired / OptionalDescription
options.methodenumRequiredThe HTTP request method, set using http.Method (e.g., GET, POST).
options.urlstringRequiredThe fully qualified HTTP/HTTPS URL being requested.
options.body`stringObject`Optional
options.headersObjectOptionalThe 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.method or options.url) are missing.

Example Syntax

Here’s a basic example demonstrating how to structure an HTTP request using SuiteScript:

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: headerObj
10});

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.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Does the N/http module support both client-side and server-side scripts?
Yes, the N/http module can be used in both client and server scripts to send HTTP requests in NetSuite.
What happens if my HTTP request takes longer than the specified timeouts?
If a connection takes longer than 5 seconds, it will time out. Similarly, if sending the request body takes longer than 45 seconds, a timeout will also occur.
Are there specific error codes I should be aware of when using the N/http module?
Yes, you may encounter error codes like SSS_INVALID_HOST_CERT for certificate issues, SSS_INVALID_URL for improperly formatted URLs, and SSS_MISSING_REQD_ARGUMENT if required parameters are missing.
Do I need to handle errors when making HTTP requests with the N/http module?
Yes, proper error handling is recommended to catch and respond to potential issues gracefully, especially when dealing with transient network conditions.
Source: Parameters Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in SuiteScript

View all SuiteScript articles →