Skip to main content

HTTP Poll

The HTTP Poll task is used to invoke HTTP API endpoints until the specified condition matches.

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 repeatedly check an HTTP service's status or output.

Task parameters

Configure these parameters for the HTTP Poll 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.terminationConditionThe condition to be evaluated after every HTTP API 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 variables. 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.pollingIntervalThe duration in seconds between each HTTP invocation. The default value is 60.Required.
inputParameters.pollingStrategyThe polling strategy. Supported values:
  • FIXED—The duration between each HTTP API 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.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.

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}"
},
"body": {
"key": "value"
}
}
}
}

Task output

The HTTP Poll 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 Poll task in UI

To add an HTTP Poll task:

  1. In your workflow, select the (+) icon and add an HTTP Poll 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 Poll 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. In Termination Condition, set the condition to be evaluated after every API invocation.
  7. Set the Polling Interval and Polling Strategy.
  8. (Optional) In Other-headers, add any additional HTTP headers to be sent along with the request.
  9. In Body, add the request body when using PUT, POST, or PATCH method.
  10. (Optional) Enable or disable Encode to specify if the URI needs to be encoded.

Adding HTTP Poll Task

Examples

Here are some examples for using the HTTP Poll task.

Sample 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.