How to get the statusCode , response body in the failureWorkflow when an http task fails due to 4xx #3683
Replies: 2 comments
-
Hi @josephjacobmorris you can mark the task as optional |
Beta Was this translation helpful? Give feedback.
-
Hi @v1r3n , Thanks for the response I tried marking the task as optional and using a switch case on the value Here is a snap of my workflow execution for 400 status code I am also attaching a sample definition of my workflow {
"createTime": 1688720424972,
"updateTime": 1688720703444,
"accessPolicy": {},
"name": "post",
"description": "Workflow used to .......",
"version": 1,
"tasks": [
{
"name": "post_task",
"taskReferenceName": "post_task",
"inputParameters": {
"http_request": {
"method": "POST",
"readTimeOut": "3600",
"body": "${workflow.input.requestbody}",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": true,
"taskDefinition": {
"accessPolicy": {},
"name": "post_task",
"description": "",
"retryCount": 2,
"timeoutSeconds": 2,
"inputKeys": [],
"outputKeys": [
"message"
],
"timeoutPolicy": "TIME_OUT_WF",
"retryLogic": "FIXED",
"retryDelaySeconds": 1,
"responseTimeoutSeconds": 1,
"concurrentExecLimit": 10,
"inputTemplate": {},
"rateLimitPerFrequency": 10,
"rateLimitFrequencyInSeconds": 1,
"ownerEmail": "[email protected]",
"backoffScaleFactor": 1
},
"asyncComplete": false
},
{
"name": "switch_update_task_status",
"taskReferenceName": "switch_update_task_status",
"inputParameters": {
"status": "${post_task.output.response.statusCode}"
},
"type": "SWITCH",
"decisionCases": {
"200": [
{
"name": "update_task_status_COMPLETED200",
"taskReferenceName": "update_task_status_COMPLETED200",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": " {\n \"status\": \"COMPLETED\",\n \"location\":\"url\"\n }\n",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
],
"201": [
{
"name": "update_task_status_COMPLETED201",
"taskReferenceName": "update_task_status_COMPLETED201",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": " {\n \"status\": \"COMPLETED\",\n \"location\":\"\"\n }\n",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
],
"400": [
{
"name": "update_task_status_REJECTED400",
"taskReferenceName": "update_task_status_REJECTED400",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": "{\n \"status\": REJECTED, \"errorMessage\": \"${post_task.output.response.body.message}\"\n }\n",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
],
"404": [
{
"name": "update_task_status_REJECTED404",
"taskReferenceName": "update_task_status_REJECTED404",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": "{\n \"status\": REJECTED, \"errorMessage\": \"${post_task.output.response.body.message}\"\n }\n",
"uri": "http://....",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
],
"500": [
{
"name": "update_task_status_FAILED500",
"taskReferenceName": "update_task_status_FAILED500",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": "{\n \"status\": FAILED, \"errorMessage\": \"${post_task.output.response.body.message}\"\n }\n",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
]
},
"defaultCase": [
{
"name": "update_task_status_COMPLETEDdefault",
"taskReferenceName": "update_task_status_COMPLETEDdefault",
"inputParameters": {
"http_request": {
"method": "PUT",
"readTimeOut": "3600",
"body": " {\n \"status\": \"COMPLETED\",\n \"location\":\"\"\n }\n",
"uri": "http://......",
"connectionTimeOut": "3600"
}
},
"type": "HTTP",
"startDelay": 0,
"optional": false,
"asyncComplete": false
}
],
"startDelay": 0,
"optional": false,
"asyncComplete": false,
"evaluatorType": "value-param",
"expression": "status"
}
],
"inputParameters": [],
"outputParameters": {
"statusCode": "${post_task.output..statusCode}",
"message": "${post_task.output..statusCode}"
},
"failureWorkflow": "update_status_failure",
"schemaVersion": 2,
"restartable": true,
"workflowStatusListenerEnabled": false,
"ownerEmail": "[email protected]",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 5,
"variables": {},
"inputTemplate": {}
}
|
Beta Was this translation helpful? Give feedback.
-
Hi, I am new to Netflix conductor
I have an HTTP task in my workflow which may fail due to 4xx due to some validation failure in the request fired. I want to pass the exact message back to the user.
I tried exploring how to pass inputs to failure workflows but the reason passed as input is a stringified version whereas I want to extract specific properties from the response body of the request fired
Beta Was this translation helpful? Give feedback.
All reactions