Skip to main content

Call an HTTP Service (APIs, Rest)

HTTP task allows you to make calls to remote services exposed over HTTP/HTTPS.

Definitions

   {
"name": "http_task",
"taskReferenceName": "http_task_ref",
"type" : "HTTP",
"inputParameters": {
"uri": "https://catfact.ninja/fact",
"method": "GET",
"connectionTimeOut": 3000,
"readTimeOut": 3000
}
}

Input Parameters

AttributeDescription
uriProvide the URI for the service. It can be a partial value when using vipAddress or it can be the server address.
methodChoose the HTTP method. Conductor supports the methods: GET, HEAD, POST, PUT, PATCH, DELETE, and OPTIONS
acceptProvide the accept header as required by the server. By default, it is set to application/json.
contentTypeProvide the content type for the server. The supported types are text/plain, text/html, and application/json. By default, it is set to application/json.
headersA map of additional http headers to be sent along with the request.
bodyRequest body when using POST or PUT.
asyncCompleteIf set, the task remains in the IN_PROGRESS state even after the execution. An external event (Task Update API or Event handler) is expected to mark the task as completed.
connectionTimeOutSet the connection timeout in milliseconds. If set to 0, it is equivalent to infinity. By default, the value is set to 100.
readTimeOutSet the read timeout in milliseconds. If set to 0, it is equivalent to infinity. By default, the value is set to 150.

Output Parameters

AttributeDescription
responseJSON body containing the response if present.
headersResponse Headers.
statusCodeHTTP Status Code.
reasonPhraseHTTP Status Code's reason phrase.

Examples



  1. Add task type HTTP.
  2. Configure the API by choosing method, endpoint, headers etc.

Adding HTTP task

Send a POST Request

    {
"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"
}

Set Read and Connect Timeouts for HTTP requests

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