HTTPGet

Overview

Retrieves information from the specified URL via a GET request. Marketing Cloud sets the timeout for this function at 30 seconds.

Syntax

HTTPGet(1, 2, 3, 4, 5)

Function Properties

Ordinal Type Description
1 string Required URL from which to retrieve content
2 Boolean Required Indicates whether GET request continues if an error occurs during the process. A value of true stops the request. A value of false allows the request to continue.
3 numeric Indicates how function handles a URL with empty content. A value of 0 allows empty content. A value of 1 returns an error. A value of 2 skips the subscriber.
4 array Required Array of header names and values to include in GET request
5 array Required Array containing HTTP code of response to function

Example

This function returns one of these status values:

  • 0 indicates status is OK
  • -1 indicates a missing URL
  • -2 indicates an HTTP request error
  • -3 indicates the function completed successfully but did not return any content
<script runat="server">
     var status = [0];
     var content = Platform.Function.HTTPGet('http://www.example.com',false,0,['x-request-id'],['sampleValue'],status);
     if(status[0] == 0) {
          Platform.Response.Write(content);
     }
</script>
Last Updated: Jun 8, 2021