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
HTTP.Get(1, 2, 3)
Properties
The HTTP.Get() function has the properties listed in this table.
| Ordinal | Type | Description |
|---|---|---|
1 |
String | Required. The destination URL for the HTTP GET request. |
2 |
Array | An array of header names to include in the request. |
3 |
Array | An array of header values to include in the request. |
Usage
This sample code performs an HTTP GET and outputs the response object.
<script runat="server">
Platform.Load('Core','1');
var url = "https://example.com/forms/myForm.html";
var headerNames = ["MyTestHeader1", "MyTestHeader2"];
var headerValues = ["MyTestValue1", "MyTestValue2"];
try {
var response = HTTP.Get(url, headerNames, headerValues);
Write(Stringify(response));
} catch(e) {
Write(Stringify(e));
}
</script>
The response is a JSON object that contains a numeric status value and the response body of the GET request.
{
"Status": 0,
"Content": "{
\"args\": {},
\"headers\": {
\"Host\": \"example.com\",
\"Mytestheader1\": \"MyTestValue1\",
\"Mytestheader2\": \"MyTestValue2\",
\"X-Amzn-Trace-Id\": \"Root=1-67ae4eb9-4b57ee616f927d773ff4f5be\"
},
\"origin\": \"203.0.113.1\",
\"url\": \"https://example.com/forms/myForm.html\"
}"
}