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.

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
Required.
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. If the condition is evaluated as true, the task is marked as completed. If the condition evaluates to false, Conductor schedules the next poll according to the configurations (pollingInterval and pollingStrategy).

When writing the termination condition, it can be passed as a dynamic variable. To use the current HTTP poll as input to the condition, prefix it with a $. For example, $.output.status. Similarly, refer to previous tasks' output using $.task_ref_name.output.

Example Termination Condition-(function(){ return $.output.response.body.randomInt > 10;})();
Required.
inputParameters.http_request. pollingInterval The duration in seconds between each HTTP invocation. The default value is 60. The minimum value must be 60 for pollInterval. 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 by multiplying the poll count by 2 base exponential powers of the pollingInterval.
By default, the polling strategy is set to FIXED.
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.
inputParameters.http_request. acceptedStatusCodes
Available since: v5.2.97 and later.
List of HTTP status codes or families to treat as successful. Supports exact codes (such as "404", "302") and family wildcards ("1xx", "2xx", "3xx", "4xx", "5xx").

When not set, only 2xx responses are treated as successful. When explicitly set, only the listed codes are accepted, i.e.; "2xx" is not implicitly included.
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 totrue, 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 A JSON object representing the response, if present.
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.
body The response body containing the data returned by the API.

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": "$.output.body.length > 10 ? true : false;",
          "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 - Evaluate whether the length of the response body ($.output.body.length) 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 (response body length > 10) evaluates to true.

Orchestrating long-running APIs

Explore the full tutorial on orchestrating long-running APIs.