http

Send a request to a HTTP endpoint.

Description

  • Send a request to a HTTP endpoint.

Parameters

Parameter

Type

Required

Default

Comment

body

str

No

Request body. This parameter is used for PUT, POST, and PATCH method.

format

str

No

text

Data format to decode a response body. It can be either text or json.

method

str

No

get

HTTP method. Following methods are available: get, put, post, patch, and delete.

out_bb

bool

No

False

out_field

str

No

None

timeout

float

No

10

Timeout in second.

url

str

Yes

-

URL.

Examples

# Get with json format
# Output: {"http": {"data": {"foo": "bar"}, "status": 200}}
- http:
    name: "http"
    url: "http://example.com/api/data"
    format: "json"

# Get with text format
# Output: {"http": {"data": '{"foo": "bar"}', "status": 200}}
- http:
    name: "http"
    url: "http://example.com/api/data"
    format: "json"

# Timeout Error
# Output: {"http": '{"error": "TimeoutError"}'}
- http:
    name: "http"
    url: "http://example.com/api/data"
    format: "json"
    timeout: "1"