HttpPost()
Posts content to the specified URL. This function only works with HTTP on port 80 and HTTPS on port 443. Non-standard port assignments cause this function to fail.
The function honors any character set returned in the content-type
HTTP header. For example, you can use a UTF-8 encoded HTML file if you specify Content-Type: text/html; charset=utf-8
in the header. If the header doesn’t specify encoding, the application assumes all returned data uses the character set WindowsCodePage 1252. To change this default setting, contact Salesforce support.
You can include as many name–value pairs as you need.
You can’t use this function to change the host
and content-length
headers. The value of host
is always set to the domain of the URL that the request was sent to. The value of content-length
is always set to the length of the content in the request.
The HttpPost()
function has six parameters:
urlEndpoint
(string): Required. The URL to post the specified content to.contentTypeHeader
(string): Required. The content-type header to use in the POST request.contentToPost
(string): Required. The content to post to the specified URL.response
(string): Required. An output parameter that contains the status of the POST request.headerName1
(string): The name of an additional header to include in the request.headerValue1
(string): The value of an additional header to include in the request.
You can pass multiple name-value pairs for parameters by appending them to the end of the function (headerName2
, headerValue2
...).
To call the function, pass it the required parameters. This example posts a simple JSON object to a specified URL. The function call uses the application/json content-type
header, and stores the status of the request in a variable called @callStatus
.
The function stores the HTTP status code in the specified variable.