HTTP Method Syntax in SuiteScript N/http Module

Understand the syntax for HTTP methods in SuiteScript's N/http module, essential for making HTTP calls.

·2 min read·View Oracle Docs

The HTTP method is a crucial part of server request handling in SuiteScript's N/http module. This specifies the action to be performed when making HTTP requests, such as retrieving or sending data.

Property Description

  • Property: The server request HTTP method.
  • Type: http.Method (read-only)
  • Module: N/http Module
  • Parent Object: http.ServerRequest

Read-Only Behavior

If you attempt to modify the method property, you will encounter the READ_ONLY_PROPERTY error, indicating that this property cannot be changed once set.

Supported HTTP Methods

The http.Method enumeration includes the following HTTP methods, each used to perform specific actions:

ValueDescription
DELETEUsed to remove resources.
GETRetrieves data from a server.
HEADFetches header information without the body.
PUTUpdates existing resources.
POSTSends data to a server for processing.
PATCHApplies partial modifications to a resource.

Syntax Example

Here is a code example illustrating how to use the HTTP method within the http module, though this is not a full functional example:

suitescript
1// Add additional code
2...
3log.debug({
4 title: 'Server Request Method',
5 details: request.method
6});
7...
8// Add additional code

For complete script examples, refer to the N/http Module Script Samples.

General Notes on HTTP Headers

While working with HTTP requests, be mindful that certain HTTP headers cannot be modified when using the N/http module. These include headers such as Connection, Content-Length, and Host. Attempting to set these headers will result in their values being discarded. Understanding these limitations is crucial for effective script development in SuiteScript.

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

Frequently Asked Questions (4)

What HTTP methods are available in the N/http module?
The N/http module supports the following HTTP methods: DELETE, GET, HEAD, PUT, POST, and PATCH, each used to perform specific actions such as retrieving or sending data.
Can the HTTP method property be modified during a request in SuiteScript?
No, the HTTP method property is read-only and cannot be changed once set. Attempting to modify it will result in a READ_ONLY_PROPERTY error.
What happens if you try to set certain HTTP headers using the N/http module?
Certain HTTP headers like Connection, Content-Length, and Host cannot be modified using the N/http module. If you attempt to set these headers, their values will be discarded.
Is there a way to see the HTTP method used in a request with the N/http module?
Yes, you can log the HTTP method used in a request with the N/http module using script functions like log.debug to output the request.method, as shown in the syntax example provided in the article.
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 →