logo
http-request
Run http-request in Direktiv
network
Updated 2 years ago
1.0

http-request

Run http-request in Direktiv as a function

Examples

Function Configuration
functions:
- id: http-request
  image: gcr.io/direktiv/functions/http-request:1.0
  type: knative-workflow
Basic
- id: http-request
  type: action
  action:
    function: http-request
    input: 
      debug: true
      url: 'https://www.direktiv.io'
      params:
        hello: world
        hello1: world2
POST Request
- id: http-request
  type: action
  action:
    function: http-request
    input: 
      url: 'https://www.direktiv.io'
      method: POST
      headers:
        header1: value1
        header2: value2
POST Request with JSON
- id: http-request
  type: action
  action:
    function: http-request
    input: 
      url: 'https://www.direktiv.io'
      method: POST
      content:
        value:
          hello: world  
          my: data
POST Request with file
- id: http-request
  type: action
  action:
    function: http-request
    input: 
      url: 'https://www.direktiv.io'
      method: POST
      content:
        kind: string
        value: 'This is the payload'
Treat 404 as error
- id: http-request
  type: action
  action:
    function: http-request
    input: 
      url: 'https://www.direktiv.io/doesnotexist'
      error200: true
  catch:
  - error: "*"                   

Secrets

No secrets required

Errors

TypeDescription
io.direktiv.command.errorCommand execution failed
io.direktiv.output.errorTemplate error for output generation of the service
io.direktiv.ri.errorCan not create information object from request

input

NameTypeDefaultDescriptionExample
urlstringURL for the request.http://www.direktiv.io
methodstringHTTP method. Defaults to GET.POST
headersmap of stringList of key/values send as headers with the request.
paramsmap of stringList of key/values appended to URL as query parameters.
usernamestringIf username and password are set, it will be used for basic authenitcation for the request.myuser
passwordstringIf username and password are set, it will be used for basic authenitcation for the request.mypassword
insecurebooleanSkips the verification the server certificate chain and host name.true
error200booleanIf set to true responses with status above 299 will be treated as errors.true
debugbooleanPrints the full URL and headers to logs.true
contentobject

content

Defines the payload of the request. The kind value can have three different values:

  • string: Plain string payload, e.g. JSON
  • base64: Will be "converted" to binary and attached
  • file: File payload, e.g. instance or workflow variables
  • json: Treat the value as JSON key/values
NameTypeDefaultDescriptionExample
kindstringjsonKind of data
valueinterface{}Value depends on kind value.

Example Response

{
   "code": 200,
   "headers": {
      "Access-Control-Allow-Origin": "*",
      "Content-Type": "text/html"
   },
   "result": "KXx8T2JqZWN0LmR...",
   "success": true
}

Quick Reference

Quick Copy
-  id : http-request
 image : gcr.io/direktiv/functions/http-request:1.0
 type : knative-workflow
Copy and paste to pull this image