3.2.9 HTTP Task

Use an HTTP task to make REST API calls to external services.

To add an HTTP Task

  1. Navigate to the Task tab in a workflow and view all the tasks that you can add using the Workflow Builder. See Access the Task Tab in Workflow Builder.

  2. In the More Tasks dialog box, click HTTP Task to add it to the workflow.
  3. Click the task that you have added in the left pane. The Task tab in the right pane displays details about the task, such as its name and parameters. Next, let's provide details for the task.

  4. In the Task Details group, enter the following information.
    • Task Name: Mandatory. Enter a unique name for the task. The name must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
    • Task Reference: Mandatory. Enter a value to refer to the task within a workflow definition. This value must be unique within a workflow. The task reference value must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
  5. In the HTTP Task Parameters group, provide the following information.
    • Request URI: Mandatory. Enter the URI of the object on which you want to perform API calls. Each object is identified uniquely by its URI.
    • HTTP Method: Mandatory. Specify the operation that you want to perform using the standard HTTP method verbs.
      • POST creates a request using the raw data in the request body. This is the default value.
      • GET retrieves data.
      • PUT updates data.
      • DELETE removes data.
    • Accept: Specify the accepted media types in the Accept header of the request.
    • Content-Type: Select the expected version of the content in an HTTP request body sent to the API server and the response.
    • Connection Timeout (ms): Maximum permissible time, in milliseconds (ms), to establish a TCP connection. Default value is 5000 ms.
    • Read Timeout (ms): Maximum permissible time, in milliseconds (ms), to read full response after connection. The default value is 60000 ms. You can tune this for large payloads, such as transaction logs.
    • Enlist in transaction: Optional. You must select this option only if you want to enlist the HTTP task as a participant service in a global XA transaction. This is disabled by default.
    • Trust self-signed certificate: Optional. Select this option when you want to use HTTPS protocol.
    • Add Header: Add headers that you want to pass in the header section of the HTTP request or response. If a server called by HTTP task supports idempotency, pass the idempotency key in the HTTP request header.
    • Body: The request body, which is required for POST and PUT HTTP methods.
  6. Click Save to save the changes to the workflow.

    MicroTx Workflows displays the changes in JSON code.

  7. Review all the changes, and then click Confirm Save to save the changes.

    If you do not want to save the changes, click Cancel, and then click Reset to undo all the changes that you have made since the workflow was last saved.

Example

When you enter information in the Task tab, the corresponding code of the task is updated in the JSON tab. The following example displays the JSON code for an HTTP task that makes REST API calls to an email notification service.

{
    "name": "Send Email notification",
    "taskReferenceName": "email_notify",
    "inputParameters": {
        "method": "POST",
        "uri": "http://notification-service:8085/email-service/sendMail",
        "headers": {
            "Content-Type": "application/json"
        },
        "body": {
            "from": "microtx.user@localhost",
            "to": "microtx.user@microtx.com",
            "cc": "",
            "subject": "Loan approval request!",
            "body": "Please approve loan req ${workflow.workflowId}",
            "isEmailBodyText": true
        }
    },
    "type": "HTTP"
}