HttpGet()

Retrieves data from a URL using the GET method.

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 via the Content-Type HTTP header. For example, you can use a UTF-8 encoded HTML file with Content-Type: text/html; charset=utf-8 included in the header. If the encoding isn’t specified in the header, the application assumes all returned data uses the WindowsCodePage 1252 character set. You can change this default by contacting Salesforce support.

In a send, if the URL is the same for multiple subscribers, the system makes one call per unique URL. Marketing Cloud Engagement caches the response and uses it for each subscriber.

The HttpGet() function has four parameters:

  • httpGetUrl (string): Required. The URL to perform the HTTP GET operation on.
  • boolContinueOnError (boolean): If true, the function ignores errors that it encounters while performing the HTTP GET operation. If false, the function exits when it encounters an error. The default value is false.
  • 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.