http:request

Perform HTTP requests using the provided configuration

Options

NameTypeDescription
urlstringThe request URL; query parameters may be embedded or provided via Query
methodstringThe HTTP method: GET, POST, PATCH, PUT, DELETE
querymap[string][]stringAdditional query parameters merged with any already in the URL
headersmap[string]stringAdditional request headers
tokenstringBearer token added to the Authorization header
token_typestringThe authorization scheme prefix (defaults to "Bearer")
bodyanyThe request body as a string or []byte

Outputs

NameTypeDescription
codeintThe HTTP response status code
bodystringThe response body as a string

Examples

Is the documented example workflow for the http component. It lives in a test file so docgen can read it for the docs without linking it into any binary. docgen keys it to the component by the config-struct name (HTTPConfig).

name: Fetch a page and save it

actions:
  - name: page
    component: http:request
    vars:
      method: GET
      url: "https://example.com/api/status"
      headers:
        Accept: application/json

  - name: save
    component: storage:local:file:write
    vars:
      path: ./status.json
      content: "{{ page.body }}"

outputs:
  code: "{{ page.code }}"

Post request

Posts a JSON body. A structured value under body is sent as JSON, and the response body comes back as a string to parse downstream.

name: Create an issue
actions:
  - name: created
    component: http:request
    vars:
      method: POST
      url: "{{ env.API }}/issues"
      headers:
        Content-Type: application/json
      body:
        title: "{{ var.title }}"
        labels:
          - automation

  - name: issue
    component: var
    vars:
      var: id
      value: "{{ created.body | from:'json' | key:'id' }}"

outputs:
  id: "{{ issue.id }}"

Authentication

Sends a bearer token and query parameters. token fills the Authorization header, token_type sets its scheme, and each query key holds a list of values.

name: Search with an API token
actions:
  - name: results
    component: http:request
    vars:
      url: "{{ env.API }}/search"
      token: "{{ env.API_TOKEN }}"
      token_type: Bearer
      query:
        q:
          - "{{ var.term }}"
        limit:
          - "10"

outputs:
  body: "{{ results.body }}"