HttpGet()
Retrieves data from a URL using the GET method. If the URL is the same for multiple subscribers in a send, Marketing Cloud Engagement makes one call per unique URL. The response is then cached and used for each subscriber.
This function only works with HTTP on port 80 and HTTPS on port 443. Non-standard port assignments cause this function to fail.
In older accounts, Marketing Cloud Engagement assumes that all returned data uses the WindowsCodePage 1252 character set. Recently created accounts use UTF-8. You can change this default by contacting Salesforce support.
The HttpGet()
function has four parameters:
httpGetUrl
(string): Required. The URL to perform the HTTP GET operation on.boolContinueOnError
(boolean): Iftrue
, the function ignores errors that it encounters while performing the HTTP GET operation. Iffalse
, the function exits when it encounters an error. The default value isfalse
.enumAllowEmptyContent
(integer): Specifies how the function handles empty content. Accepted values:0
: Allow empty content. This is the default behavior.1
: Return an error when the function encounters empty content.2
: Skip sending an email to a subscriber when you use the function in an email.
functionStatusOutput
(integer): A variable that holds the status of the function. Possible values:0
: Indicates that the function completed successfully.-1
: Indicates that the function failed because the specified wasn’t found.-2
: Indicates that the function failed because of an HTTP request error.-3
: Indicates that the function completed successfully but didn’t return any content.
To use the function, pass it the URL of a site that you want to retrieve.
The function returns the content of http://www.example.com
.
You can use conditional logic to handle errors. In this example, the function continues if it encounters an error, and it allows empty content. The result of the function is stored in the variable @callStatus
.
The function returns the content of http://www.example.com
if it’s available, and a message if it isn’t available.