Skip to content

HTTP Poll

An HTTP Poll task sends HTTP requests to a specified endpoint at regular intervals and continues until a given termination condition is met. This is useful when you need to check the status or output of an HTTP service repeatedly.

You can reuse an HTTP service registered in Remote Services to populate the HTTP Poll task's endpoint details. Global service settings apply to HTTP Poll tasks, but circuit breaker settings apply only to HTTP tasks.

Task parameters

Configure these parameters for the HTTP Poll task.

Parameter Description Required/ Optional
inputParameters.http_request. uri The URI for the service. It can be a partial value when using vipAddress or it can be the server address. Required.
inputParameters.http_request. method The HTTP method. Supported methods:
  • GET
  • HEAD
  • POST
  • PUT
  • PATCH
  • DELETE
  • OPTIONS
  • TRACE
The default value is GET.
Optional.
inputParameters.http_request. accept The 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
Any other headers can be passed as a dynamic variable.
Optional.
inputParameters.http_request. contentType The 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
It can be passed as a dynamic variable.
Optional.
inputParameters.http_request. terminationCondition The condition to be evaluated after every HTTP invocation. It can return a boolean or a number:
  • true or 1: The task is marked as completed.
  • false or 0: Conductor schedules the next poll according to pollingInterval and pollingStrategy.
  • -1: The task is marked as failed.

The termination condition can be passed as a dynamic variable. In the script, use $.output to read the current poll's output, such as $.output.response.statusCode, and $.input to read the task's input parameters. To use a previous task's output, add it as a task input parameter alongside http_request, such as "previousStatus": "${task_ref_name.output.status}", and read it in the script with $.input.previousStatus.

Example Termination Condition-(function(){ return $.output.response.body.randomInt > 10;})();
Required.
inputParameters.http_request. pollingInterval The duration in seconds between each HTTP invocation. The minimum value is 60 by default. If you set a lower value, Conductor uses the minimum instead. If this parameter is not set, the task fails when it schedules the next poll. Required.
inputParameters.http_request. pollingStrategy The polling strategy. Supported values:
  • FIXED: The duration between each HTTP invocation remains constant.
  • LINEAR_BACKOFF: The duration between invocations increases linearly, calculated by multiplying the poll count with the pollingInterval. Note that the poll count increments with each invocation.
  • EXPONENTIAL_BACKOFF: The duration between invocations increases exponentially, calculated as pollingInterval multiplied by 2 to the power of the poll count.
If this parameter is not set, the task fails when it schedules the next poll.
Required.
inputParameters.http_request. headers A 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.http_request. body The 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.http_request. encode Determines 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.

The following are generic configuration parameters that can be applied to the task and are not specific to the HTTP Poll task.

Caching parameters

You can cache the task outputs using the following parameters. Refer to Caching Task Outputs for a full guide.

Parameter Description Required/ Optional
cacheConfig.ttlInSecond The time to live in seconds, which is the duration for the output to be cached. Required if using cacheConfig.
cacheConfig.key The cache key is a unique identifier for the cached output and must be constructed exclusively from the task’s input parameters.
It can be a string concatenation that contains the task’s input keys, such as ${uri}-${method} or re_${uri}_${method}.
Required if using cacheConfig.
Other generic parameters

Here are other parameters for configuring the task behavior.

Parameter Description Required/ Optional
optional Whether the task is optional.

If set to true, any task failure is ignored, and the workflow continues with the task status updated to COMPLETED_WITH_ERRORS. However, the task must reach a terminal state. If the task remains incomplete, the workflow waits until it reaches a terminal state before proceeding.
Optional.

Task configuration

This is the task configuration for an HTTP Poll task.

{
     "name": "http_poll",
     "taskReferenceName": "http_poll_ref",
     "type": "HTTP_POLL",
     "inputParameters": {
       "http_request": {
         "uri": "https://orkes-api-tester.orkesconductor.com/api",
         "method": "GET",
         "accept": "application/json",
         "contentType": "application/json",
         "terminationCondition": "(function(){ return $.output.response.body.randomInt > 10;})();",
         "pollingInterval": 60,
         "pollingStrategy": "FIXED",
         "encode": true,
         "headers": {
           "header-1": "${workflow.input.header-1}"
         }
       }
     }
}

Task output

The HTTP Poll task will return the following parameters.

Parameter Description
response The HTTP response from the last poll. It contains:
  • body: The response body containing the data returned by the API.
  • headers: An object containing the metadata about the response.
  • statusCode: The HTTP status code indicating success or failure of the request.
  • reasonPhrase: The reason phrase associated with the HTTP status code.

Examples

Here are some examples for using the HTTP Poll task.

Using HTTP Poll task in a workflow

To demonstrate the HTTP Poll task, consider the following sample workflow.

{
  "name": "your_workflow_name",
  "description": "Sample workflow to get started with HTTP POLL task.",
  "tasks": [
    {
      "name": "example",
      "taskReferenceName": "example",
      "inputParameters": {
        "http_request": {
          "uri": "https://jsonplaceholder.typicode.com/posts/1",
          "method": "GET",
          "terminationCondition": "(function(){ return $.output.response.body.body.length > 10; })();",
          "pollingInterval": "60",
          "pollingStrategy": "FIXED"
        }
      },
      "type": "HTTP_POLL"
    }
  ]
}

In this configuration, the polling conditions are configured as follows:

  • uri - Specifies the endpoint to be called (https://jsonplaceholder.typicode.com/posts/1 in this example).
  • method - Defines the HTTP method used for the request (GET in this case).
  • terminationCondition - Evaluates whether the length of the body field in the response ($.output.response.body.body) exceeds ten characters to determine task completion.
  • pollingInterval - Sets the interval (60 seconds) between successive API invocations.
  • pollingStrategy - Utilizes a FIXED strategy to maintain a constant interval between invocations.

Conductor will execute the HTTP API call every 60 seconds until the condition evaluates to true.

Orchestrating long-running APIs

Explore the full tutorial on orchestrating long-running APIs.