HTTP PUT Request Syntax in SuiteScript 2.x

Learn the syntax for HTTP PUT requests in SuiteScript 2.x, including parameters and common errors.

·2 min read·View Oracle Docs

TL;DR Opening

This article explains how to execute an HTTP PUT request using SuiteScript 2.x, focusing on the syntax, parameters, and potential errors to be aware of in your scripting.

Method Description

The HTTP PUT request method allows you to send data to a specific URL. However, it has some important timeout limitations:

  • Connection timeout: 5 seconds
  • Data sending timeout: 45 seconds

Note that the PUT request is not functional in unauthenticated client-side contexts, which is crucial for ensuring secure interactions. For further information, refer to the relevant documentation on HTTP requests.

Returns

The PUT request method returns either a http.ClientResponse or http.ServerResponse.

Supported Script Types

  • Client Scripts
  • Server Scripts

For additional details, check out the SuiteScript 2.x Script Types.

Governance

Using the HTTP PUT method consumes 10 governance units.

Parameters

The options parameter is a JavaScript object containing several key properties:

ParameterTypeRequired / OptionalDescription
options.bodystring  ObjectRequiredThe data payload sent with the request.
options.urlstringRequiredThe HTTP URL to which the request is sent.
options.headersObjectOptionalCustom headers for the request.

Errors

Here are the common error codes you might encounter when performing a PUT request:

Error CodeMessageThrown If
SSS_INVALID_HOST_CERTAn untrusted, unsupported, or invalid certificate was found for this host.Security negotiation fails or domain issues.
SSS_INVALID_URLThe URL must be a fully qualified HTTP/HTTPS URL.Invalid URL specified in options.url.
SSS_MISSING_REQD_ARGUMENTMissing a required argument: {param name}options.body or options.url not specified.

Example Syntax

Below is a code sample illustrating the syntax used for the HTTP PUT request, although it is not a complete functional example:

suitescript
1// Add additional code
2...
3var headerObj = {
4 name: 'Accept-Language',
5 value: 'en-us'
6};
7var response = http.put({
8 url: 'http://www.google.com',
9 body: 'My PUT Data',
10 headers: headerObj
11});
12...
13// Add additional code

Related Topics

Key Takeaways

  • The HTTP PUT method is critical for sending data to specified URLs.
  • Timeout settings can affect request success; understand these limitations.
  • Ensure all required parameters are included to avoid common errors.

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

Frequently Asked Questions (4)

What script types support HTTP PUT requests in SuiteScript 2.x?
HTTP PUT requests in SuiteScript 2.x are supported in both Client Scripts and Server Scripts.
What are the required parameters for executing an HTTP PUT request in SuiteScript 2.x?
The required parameters for an HTTP PUT request include the 'options.body' to define the data payload and the 'options.url' to specify the target URL.
What happens if I use an invalid URL in an HTTP PUT request?
If an invalid URL is specified in the 'options.url', you'll encounter the error code 'SSS_INVALID_URL', indicating that the URL must be a fully qualified HTTP/HTTPS URL.
What are the timeout limitations for HTTP PUT requests in SuiteScript 2.x?
There are two timeout limitations: a connection timeout of 5 seconds and a data sending timeout of 45 seconds.
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 →