Sends a synchronous HTTP request and returns the response.
When a body is provided, the Content-Type header is automatically
set to application/json.
The full URL to send the request to.
HTTP method.
Optionalbody: stringOptional JSON string to send as the request body.
An HttpResponse with the status code and response body.
A statusCode of 0 indicates a network-level failure (timeout, DNS error, connection refused) — not an HTTP error. Always check statusCode === 0 separately from HTTP 4xx/5xx errors. Request timeout is 30 s; connection timeout is 10 s.
// GET request
const res = HTTP.SendRequest("https://api.example.com/data", "GET");
if (res.statusCode === 0) {
Console.Error("Network error: " + res.body);
} else if (res.statusCode === 200) {
const data = JSON.parse(res.body);
Console.Log(data.value);
}
// POST with JSON body
const post = HTTP.SendRequest(
"https://api.example.com/items",
"POST",
JSON.stringify({ name: "test" })
);