HTTP.Get()

Performs an HTTP GET by using the provided name and value pairs against the passed URL, and it returns a JSON object that contains a status value and the HTTP response. You can include multiple pairs of header names and values. This function only works with HTTP on port 80 and HTTPS on port 443.

Syntax 

1HTTP.Get(1, 2, 3)

Properties 

The HTTP.Get() function has the properties listed in this table.

OrdinalTypeDescription
1StringRequired. The destination URL for the HTTP GET request.
2ArrayAn array of header names to include in the request.
3ArrayAn array of header values to include in the request.

Usage 

This sample code performs an HTTP GET and outputs the response object.

1<script runat="server">
2  Platform.Load('Core','1');
3
4  var url = "https://example.com/forms/myForm.html";
5  var headerNames = ["MyTestHeader1", "MyTestHeader2"];
6  var headerValues = ["MyTestValue1", "MyTestValue2"];
7
8  try {
9    var response = HTTP.Get(url, headerNames, headerValues);
10    Write(Stringify(response));
11  } catch(e) {
12    Write(Stringify(e));
13  }
14</script>

The response is a JSON object that contains a numeric status value and the response body of the GET request.

1{
2  "Status": 0,
3  "Content": "{
4    \"args\": {},
5    \"headers\": {
6      \"Host\": \"example.com\",
7      \"Mytestheader1\": \"MyTestValue1\",
8      \"Mytestheader2\": \"MyTestValue2\",
9      \"X-Amzn-Trace-Id\": \"Root=1-67ae4eb9-4b57ee616f927d773ff4f5be\"
10    },
11    \"origin\": \"203.0.113.1\",
12    \"url\": \"https://example.com/forms/myForm.html\"
13  }"
14}

See Also