Skip to main content

HttpTask

The adapter will report the text body of a successful HTTP request to the specified url, or return an error if the response status code is greater than or equal to 400.

Input: None

Returns: String representation of the http response.

Example: Basic HttpTask

{
"httpTask": {
"url": "https://mywebsite.org/path"
}
}

Example: HttpTask example with headers

{
"httpTask": {
"url": "https://mywebsite.org/path",
"method": "METHOD_POST",
"headers": [
{
"key": "MY_HEADER_KEY",
"value": "MY_HEADER_VALUE"
}
],
"body": "{\"MY_BODY_KEY\":\"MY_BODY_VALUE\"}"
}
}

See the HttpTask typescript definition in @switchboard-xyz/common

Fields

NameTypeDescription
 url

string

A string containing the URL to direct this HTTP request to.

 method

The type of HTTP request to make.

 headers

A list of headers to add to this HttpTask.

 body

string

A stringified body (if any) to add to this HttpTask.

Enums

 Method

An enumeration representing the types of HTTP requests available to make.

ValueNameDescription
 0METHOD_UNKOWN

Unset HTTP method will default to METHOD_GET

 1METHOD_GET

Perform an HTTP ‘GET’ request.

 2METHOD_POST

Perform an HTTP ‘POST’ request.

Messages