The full URL to send the request to.
Optionalmethod: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"
HTTP method. Defaults to GET.
Optionalbody: HttpRequestBody
Optional JSON-serializable body. Omit or pass null for no body. Strings are sent verbatim; other values are JSON-serialized.
A promise for an HttpResponse with the status code and response body.
Network-level failures (timeout, DNS error, connection refusal, or response-body read failure) reject the Promise and should be handled with try/catch. HTTP 4xx/5xx responses resolve normally with their real status code. Request timeout is 30 s; connection timeout is 10 s. Method matching is case-insensitive at runtime; the uppercase spellings in the type are canonical.
// GET request
try {
const res = await HTTP.SendRequest("https://api.example.com/data", "GET");
if (res.statusCode === 200) {
const data = JSON.parse(res.body);
Console.Log(data.value);
}
} catch (error) {
Console.Error("Network error: " + error);
}
// POST with JSON body
const post = await HTTP.SendRequest(
"https://api.example.com/items",
"POST",
{ name: "test" }
);
Sends an HTTP request and resolves with the response.
When a non-null
bodyis provided, theContent-Typeheader is automatically set toapplication/json. Strings are sent verbatim; other accepted values are serialized as compact JSON text.