Skip to main content

HTTP

The HTTP task is used to make calls to remote services exposed over HTTP/HTTPS. It supports various HTTP methods, headers, body content, and other configurations needed for interacting with APIs or remote services.

The HTTP task evaluates the parameters provided, constructs the HTTP request accordingly, and sends it to the specified URI. It handles the response by extracting useful information like status code, headers, and body content, which can be used in subsequent tasks in the workflow.

Task parameters

Configure these parameters for the HTTP task.

ParameterDescriptionRequired/Optional
inputParameters.uriThe URI for the service. It can be a partial value when using vipAddress or it can be the server address.Required.
inputParameters.methodThe HTTP method. Supported methods:
  • GET
  • HEAD
  • POST
  • PUT
  • PATCH
  • DELETE
  • OPTIONS
  • TRACE
Required.
inputParameters.acceptThe accept header required by the server. The default value is application/json. Supported types:
  • application/java-archive
  • application/EDI-X12
  • application/EDIFACT
  • application/javascript
  • application/octet-stream
  • application/ogg
  • application/pdf
  • application/xhtml+xml
  • application/x-shockwave-flash
  • application/json
  • application/ld+json
  • application/xml
  • application/zip
  • application/x-www-form-urlencoded
  • audio/mpeg
  • audio/x-ms-wma
  • audio/vnd.rn-realaudio
  • audio/x-wav
  • image/gif
  • image/jpeg
  • image/png
  • image/tiff
  • image/vnd.microsoft.icon
  • image/x-icon
  • image/vnd.djvu
  • image/svg+xml
You can pass any other headers as variables.
Optional.
inputParameters.contentTypeThe content type for the server. The default value is application/json. Supported types:
  • application/java-archive
  • application/EDI-X12
  • application/EDIFACT
  • application/javascript
  • application/octet-stream
  • application/ogg
  • application/pdf
  • application/xhtml+xml
  • application/x-shockwave-flash
  • application/json
  • application/ld+json
  • application/xml
  • application/zip
  • application/x-www-form-urlencoded
  • audio/mpeg
  • audio/x-ms-wma
  • audio/vnd.rn-realaudio
  • audio/x-wav
  • image/gif
  • image/jpeg
  • image/png
  • image/tiff
  • image/vnd.microsoft.icon
  • image/x-icon
  • image/vnd.djvu
  • image/svg+xml
You can pass this as variables.
Optional.
inputParameters.headersA map of additional HTTP headers to be sent along with the request. Supported types:
  • Accept-Language
  • Authorization
  • Cache Control
  • Content-MD5
  • From
  • If-Match
  • If-Modified-Since
  • If-None-Match
  • Max-Forwards
  • Pragma
  • If-Range
  • If-Unmodified-Since
  • Proxy-Authorization
  • Range
  • Warning
  • x-api-key
  • Accept-Charset
  • Accept-Encoding
  • Accept-Control-Request-Headers
  • Accept-Control-Request-Method
  • Content-Transfer-Encoding
  • Expect
  • Transfer-Encoding
  • Trailer
Optional.
inputParameters.bodyThe request body for POST, PUT, or PATCH methods. Can be text or parameters such as string, number, boolean, null, or object/array.Required for POST, PUT, or PATCH.
inputParameters.encodeDetermines whether the URI needs encoding. When set to true, the Conductor will automatically encode the query parameters before sending the HTTP request. Set this to false if the URI is already encoded. The default value is true.Optional.
inputParameters.asyncCompleteWhen turned on, task completion occurs asynchronously, with the task remaining in progress while waiting for external APIs or events to complete the task.Optional.

Task configuration

This is the task configuration for an HTTP task.

  {
"name": "http",
"taskReferenceName": "http_ref",
"type": "HTTP",
"inputParameters": {
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"accept": "application/json",
"contentType": "application/json",
"encode": true,
"headers": {
"header-1": "${workflow.input.header-1}"
},
"body": {
"key": "value"
}
},
"asyncComplete": true
}

Task output

The HTTP task will return the following parameters.

ParameterDescription
responseA JSON object representing the response, if present.
headersAn object containing the metadata about the response.
statusCodeThe HTTP status code indicating success or failure of the request.
reasonPhraseThe reason phrase associated with the HTTP status code.
bodyThe response body containing the data returned by the API.

Adding an HTTP task in UI

To add an HTTP task:

  1. In your workflow, select the (+) icon and add an HTTP task.
  2. Choose the HTTP method for sending requests from the Method drop-down.
  3. In URL, add the URI to be called by the HTTP task.
  4. In Accept, select the accept header as required by the server.
  5. In Content-Type, select the content type for the server.
  6. (Optional) In Other-headers, add any additional HTTP headers to be sent along with the request.
  7. In Body, add the request body when using PUT, POST, or PATCH method.
  8. (Optional) Enable or disable Encode to specify if the URI needs to be encoded.
  9. (Optional) Set Async complete to true if the task is to be completed asynchronously.

Adding HTTP task

Examples

Here are some examples for using the HTTP task.

Sending a POST request

Sample workflow for sending an HTTP POST request:

//task definition

{
"name": "http_post_example",
"taskReferenceName": "post_example",
"inputParameters": {
"http_request": {
"uri": "https://jsonplaceholder.typicode.com/posts/",
"method": "POST",
"body": {
"title": "${get_example.output.response.body.title}",
"userId": "${get_example.output.response.body.userId}",
"action": "doSomething"
}
}
},
"type": "HTTP"
}

Sample Workflow using ‘Async Complete’ option

The asyncComplete option in the HTTP task configuration allows tasks to be marked as completed asynchronously, providing flexibility in workflow execution. Here's an example enabling ‘asyncComplete’:

{
"name": "async_complete_example",
"description": "Edit or extend this sample workflow. Set the workflow name to get started",
"version": 1,
"tasks": [
{
"name": "http_task_85tf2",
"taskReferenceName": "http_task_85tf2_ref",
"inputParameters": {
"http_request": {
"uri": "https://orkes-api-tester.orkesconductor.com/api",
"method": "GET",
"connectionTimeOut": 3000,
"readTimeOut": "3000",
"accept": "application/json",
"contentType": "application/json"
}
},
"type": "HTTP",
"asyncComplete": true
}
],
"schemaVersion": 2,
"ownerEmail": "john.doe@acme.com"
}

Now, let’s run this in the Developer Edition.

Run in Orkes Developer Edition

  1. Under Workflow Name, choose async_complete_example.
  2. Click Run Workflow.

Upon execution, the HTTP task remains “Scheduled” instead of completing immediately, allowing for asynchronous completion. The task can be completed using various methods:

Once the workflow runs, note the generated workflowId displayed near the workflow name on the execution page.

Workflow ID in Conductor

Use this workflowId along with the taskRefName to complete the task via the following API:

POST /api/tasks/{workflowId}/{taskRefName}/{status}

Employing these methods allows you to asynchronously complete your workflow, which is beneficial when pausing the workflow for external interventions.