HTTP DELETE Request Syntax in SuiteScript 2.0

Learn the syntax for making HTTP DELETE requests in SuiteScript 2.0, including required parameters and error handling.

·2 min read·View Oracle Docs

The HTTP DELETE request in SuiteScript 2.0 sends a request to delete a specified resource from a server. Understanding how to construct this request is essential for developers looking to implement server communications effectively.

Method Description

Sending an HTTP DELETE request can allow you to manage server resources by removing unwanted entries. Here are some key points regarding the DELETE method:

  • Timeouts: If it takes longer than 5 seconds to connect to the server, the request will time out. If sending the request payload exceeds 45 seconds, it will also time out.
  • Client-Side Context: This method cannot be executed in unauthenticated client-side contexts, which means proper authentication is crucial.

Returns

The DELETE request can return either a http.ClientResponse or http.ServerResponse, depending on the context in which the request is made.

Supported Script Types

  • Client scripts
  • Server scripts

For more information, consult the SuiteScript 2.x Script Types documentation.

Governance

Each call for the DELETE request counts as 10 governance units.

Parameters

The method utilizes an options parameter, which is a JavaScript object, structured as follows:

ParameterTypeRequired / OptionalDescription
options.urlstringrequiredThe HTTP URL being requested.
options.headersObjectoptionalThe HTTP headers you want to include.

Note: In DELETE requests, a request body is not necessary.

Error Handling

When executing the DELETE request, various errors might occur. Here are some common error codes you should be aware of:

Error CodeMessageThrown If
SSS_INVALID_HOST_CERTAn untrusted or invalid certificate was found for this host.Security negotiation failed or domain name is invalid.
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 missing.

Syntax Example

The following code snippet demonstrates the correct usage of the HTTP DELETE method:

suitescript
1var headerObj = {
2 name: 'Accept-Language',
3 value: 'en-us'
4};
5var response = http.delete({
6 url: 'http://www.mytestwebsite.com',
7 headers: headerObj
8});

For more extensive scripting examples, refer to the N/http Module Script Samples.

Key Takeaways

  • The HTTP DELETE request is utilized to remove resources from a server.
  • Proper construction of the options parameter is essential, particularly for the url.
  • Careful error handling is crucial to ensure reliable server communications.

Frequently Asked Questions (4)

What permissions are required to execute HTTP DELETE requests in SuiteScript 2.0?
The DELETE request cannot be executed in unauthenticated client-side contexts, so proper authentication is required to ensure the request can be made.
Are there any timeout constraints for HTTP DELETE requests in SuiteScript 2.0?
Yes, if it takes longer than 5 seconds to connect to the server or sending the request payload exceeds 45 seconds, the HTTP DELETE request will time out.
What types of scripts support using the HTTP DELETE method in SuiteScript 2.0?
The HTTP DELETE method can be used in both client scripts and server scripts within SuiteScript 2.0.
How does an invalid URL affect HTTP DELETE requests in SuiteScript 2.0?
If an invalid URL is specified in the `options.url` parameter, it will throw an error with the code `SSS_INVALID_URL`, indicating that the URL must be a fully qualified HTTP/HTTPS URL.
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 →