HTTP Request Parameters in SuiteScript for Integration

Learn about HTTP request parameters in SuiteScript, including methods, headers, and error handling for effective integrations.

·3 min read·6 views·View Oracle Docs

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:

ParameterTypeRequired/OptionalDescription
options.methodenumRequiredThe HTTP method for the request, set using http.Method.
options.urlstringRequiredThe target HTTP URL for the request.
options.bodystringObjectOptional
options.headersObjectOptionalHTTP 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 CodeMessageThrown If
SSS_INVALID_HOST_CERTAn 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_URLThe URL must be a fully qualified HTTP/HTTPS URL.The specified URL in options.url is incorrect.
SSS_MISSING_REQD_ARGUMENTMissing 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:

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.example.com',
8 body: 'My REQUEST Data',
9 headers: headerObj
10});

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?
The HTTP request parameters in SuiteScript 2026.1 support multiple methods including GET, POST, PUT, and DELETE. This enables developers to align their requests with the conventions of the target APIs.
How can developers handle errors related to HTTP requests in SuiteScript?
Developers can handle errors using specific error codes such as SSS_INVALID_HOST_CERT for untrusted certificates and SSS_INVALID_URL for malformed URLs, which help in diagnosing and resolving issues quickly.
Are there any governance limitations associated with making HTTP requests in NetSuite SuiteScript?
Yes, each HTTP request consumes 10 governance units, which developers should consider to manage their script's governance budget effectively.
What happens if the connection or request takes too long in SuiteScript 2026.1?
In SuiteScript 2026.1, a connection will timeout if it takes more than 5 seconds to establish, and a request will timeout if the payload takes more than 45 seconds to send. This ensures that scripts remain responsive.

Weekly Update History (1)

SuiteScriptadded

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 Docs
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 →