HTTP Request Service Task

Allows to perform HTTP(S) calls, and map results of the response back to fields or variables.

To add an HTTP Request Service task, we need to define it into our process YAML file, and then select it from a service task step using the BPMN Editor.

For example, let’s say we need to find a score, which is calculated by a complex logic that lives in a serverless function.

# myProcess.yml
serviceTasks:

  calculateScore:

    name: Calculate score

    # type: should be "httpRequest"
    type: httpRequest

    # retries, optional. Default 3.
    retries: 3

    # method: Defines the method to use
    # Required. Can be any of GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
    method: POST

    # url: The URL. Can contain fields or variables (using double curly braces)
    # Required
    url: http://example.com/myEndpoint/{{candidate.email}}

    # query: Key/Value pairs for the query string
    # object, optional
    query:

      # the key of this object can be any text
      # the value can be any:
      # - text
      # - field - {{candidate.id}}
      # - variable - {{_vars.initiator.email}}
      # - secret - {{_secrets.mySecret}}
      # - a mix of them
      a: any text
      b: "{{text_candidate.uuid_id}}"
      d: "{{_secrets.mySecret}}"
      e: "{{_vars.initiator.id}}"
      f: A mix of anything {{_vars.initiator.email}} {{_secrets.abc}}

    # headers: key/value pairs of the headers to be sent to the request
    # object, optional
    headers:

      # the key of this object can be any text
      # the value can be any text, field, variable, secret or a mix of them
      Authorization: Bearer {{_secrets.myToken}}

    # Body: The body to be sent in the HTTP Request.
    # optional, can be either:
    # - a string
    # - an object
    #
    # if body is a string, it can be multiline, and can include any fields, variables, secrets.
    # body: this is the body to be sent {{candidate.id}}
    #
    # if body is an object, the object properties will be sent as form data
    body:

      myKey: myValue
      anotherKey: "{{_secrets.mySecret}} {{candidate.firstName}}"

    # mapping: Configures how the result will be processed
    # object, optional
    mapping:

      # key can be any of:
      # - a field name (e.g. candidate.score)
      # - a variable name (e.g. _vars.myVar)
      #
      # you can use any of these values (using double braces)
      # - body
      # - a property of body (e.g. body.data or body.data.a.b.c[1])
      # - statusCode
      # - headers
      # - a specific header (e.g. headers.myHeader)
      myField: Lorem ipsum {{body.data.scoreDescription}}
      candidate.score: "{{body.data.score}}"
      _vars.response: "{{body}}"
      _vars.statusCode: "{{statusCode}}"
      _vars.expireDate: "{{headers.expires}}"

Then we just need to select the service task from the BPMN Editor.

HTTP Request Service Task

More information in the HTTP Request YAML Reference documentation.