HTTP GET Request Syntax in SuiteScript

Understand the syntax for sending HTTP GET requests in SuiteScript, including key parameters and potential errors.

·2 min read·View Oracle Docs

TL;DR Opening

This article explains how to construct an HTTP GET request in SuiteScript, including required parameters, error handling, and usage scenarios. Understanding this syntax is vital for integrating external data and services within NetSuite.

Method Description

The HTTP GET request method is used to retrieve data from a specified URL. It's essential to note that this method does not function in unauthenticated client-side contexts. For more details, reference the SuiteAnswers article on Outbound HTTPS in an unauthenticated client-side context.

Returns

The method can return either an http.ClientResponse or an http.ServerResponse, depending on the context in which it is executed.

Supported Script Types

The GET request method is compatible with both client-side and server-side scripts. For further details on script types, refer to the SuiteScript 2.x Script Types.

Governance

Executing an HTTP GET request consumes 10 governance units.

Parameters

The options parameter is a JavaScript object that allows for customization of the request. Below are the parameters:

ParameterTypeRequired / OptionalDescription
options.urlstringRequiredThe HTTP URL being requested.
options.headersObjectOptionalThe HTTP headers to include with the request. For more information, see HTTP Header Information.

Errors

You may encounter various errors when executing an HTTP GET request. Here are some common ones:

Error CodeMessageThrown If
SSS_INVALID_HOST_CERTAn untrusted, unsupported, or invalid certificate was found for this host.The connection is unusable due to security negotiation issues. Check domain spelling and syntax.
SSS_INVALID_URLThe URL must be a fully qualified HTTP/HTTPS URL.An invalid URL is specified in the options.url parameter.
SSS_MISSING_REQD_ARGUMENTMissing a required argument: {param name}The options.url parameter is not specified.

Syntax

The following code snippet illustrates the syntax for the HTTP GET request method. Note that this is a basic framework and not a functional example:

suitescript
1// Initialize request header
2var headerObj = {
3 name: 'Accept-Language',
4 value: 'en-us'
5};
6
7// Send the GET request
8var response = http.get({
9 url: 'http://www.google.com',
10 headers: headerObj
11});

Related Topics

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

Key Takeaways

  • The HTTP GET request method retrieves data from a specified URL.
  • It's incompatible with unauthenticated client-side contexts.
  • Error codes can inform users about invalid certificates or URLs and missing parameters.
  • Proper syntax and parameter usage are critical for successful implementation.

Frequently Asked Questions (4)

Does the HTTP GET request method in SuiteScript work in both client-side and server-side scripts?
Yes, the HTTP GET request method is compatible with both client-side and server-side scripts in SuiteScript.
What are the required parameters for sending an HTTP GET request in SuiteScript?
The only required parameter for sending an HTTP GET request in SuiteScript is `options.url`, which should be a fully qualified HTTP/HTTPS URL.
What error codes might I encounter when executing an HTTP GET request in SuiteScript, and what do they mean?
Common error codes include `SSS_INVALID_HOST_CERT` for invalid certificates, `SSS_INVALID_URL` for improperly formatted URLs, and `SSS_MISSING_REQD_ARGUMENT` when the `options.url` parameter is not specified.
How many governance units does executing an HTTP GET request consume in SuiteScript?
Executing an HTTP GET request in SuiteScript consumes 10 governance units.
Source: Syntax 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 Integration

View all Integration articles →