http.post(options)
Method Description |
Sends an HTTP POST request.
Important:
If negotiating a connection to the destination server exceeds 5 seconds, a connection timeout occurs. If transferring a payload to the server exceeds 45 seconds, a request timeout occurs. |
Returns |
|
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Since |
2015.2 |
Parameters
The options
parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string | Object |
required |
The POST data.
Note:
Sending a file using multipart/form-data content type in the |
2015.2 |
|
string |
required |
The HTTP URL being requested. For information about resolving a URL, see N/url Module. For information about getting the URL for a script, including Suitelets, see url.resolveScript(options). |
2015.2 |
|
Object |
optional |
The HTTP headers. For more information, see HTTP Header Information. |
2015.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
An untrusted, unsupported, or invalid certificate was found for this host. |
The client and server could not negotiate the desired level of security. The connection is no longer usable. You may also receive this error if the domain name in the
|
|
The URL must be a fully qualified HTTP/HTTPS URL. |
The URL specified in the For information about resolving a URL, see N/url Module. |
|
Missing a required argument: {param name}. |
The |
|
This script executes a recursive function that has exceeded the limit for the number of times a script can call itself using an HTTP request. Please examine the script for a potential infinite recursion problem. |
A script is calling back into itself recursively using an HTTP/HTTPS request. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/http Module Script Samples.
// Add additional code
...
var headerObj = {
name: 'Accept-Language',
value: 'en-us'
};
var response = http.post({
url: 'http://www.testwebsite.com',
body: 'My POST Data',
headers: headerObj
});
var myresponse_body = response.body; // see http.ClientResponse.body
var myresponse_code = response.code; // see http.ClientResponse.code
var myresponse_headers = response.headers; // see http.Clientresponse.headers
...
// Add additional code