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.
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:
| Parameter | Type | Required / Optional | Description |
|---|---|---|---|
options.url | string | required | The HTTP URL being requested. |
options.headers | Object | optional | The 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 Code | Message | Thrown If |
|---|---|---|
SSS_INVALID_HOST_CERT | An untrusted or invalid certificate was found for this host. | Security negotiation failed or domain name is invalid. |
SSS_INVALID_URL | The URL must be a fully qualified HTTP/HTTPS URL. | An invalid URL is specified in the options.url parameter. |
SSS_MISSING_REQD_ARGUMENT | Missing 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:
1var headerObj = {2 name: 'Accept-Language',3 value: 'en-us'4};5var response = http.delete({6 url: 'http://www.mytestwebsite.com',7 headers: headerObj8});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
optionsparameter is essential, particularly for theurl. - 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?
Are there any timeout constraints for HTTP DELETE requests in SuiteScript 2.0?
What types of scripts support using the HTTP DELETE method in SuiteScript 2.0?
How does an invalid URL affect HTTP DELETE requests in SuiteScript 2.0?
Was this article helpful?
More in SuiteScript
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category