Resolving incident by Postman

Hi guys!
I am trying to resolve many incidents by Postman.
So, I set up a Postman order like this:
GET {{base-url}}/rest/incident?processDefinitionId=CheckoutWebFlow:3:0c1a0e90-334b-11eb-8c3b-5e93526b4bdc&activityId=UpdateCheckoutStatusAcceptedTask&maxResults=1

I got this result:
[
{
“id”: “0a171d7c-54db-11eb-ae13-be347f09790a”,
“processDefinitionId”: “CheckoutWebFlow:3:0c1a0e90-334b-11eb-8c3b-5e93526b4bdc”,
“processInstanceId”: “3971fac7-1e9a-11eb-adbc-2a10bcbe5ba9”,
“executionId”: “3971fac7-1e9a-11eb-adbc-2a10bcbe5ba9”,
“incidentTimestamp”: “2021-01-12T10:35:31.000-0300”,
“incidentType”: “failedJob”,
“activityId”: “UpdateCheckoutStatusAcceptedTask”,
“causeIncidentId”: “0a171d7c-54db-11eb-ae13-be347f09790a”,
“rootCauseIncidentId”: “0a171d7c-54db-11eb-ae13-be347f09790a”,
“configuration”: “3994ec37-1e9a-11eb-adbc-2a10bcbe5ba9”,
“incidentMessage”: “Error Deleting 500 Internal Server Error”,
“tenantId”: null,
“jobDefinitionId”: “0c1a35a1-334b-11eb-8c3b-5e93526b4bdc”
}
]

And in the Postman’s test guide I put this script:
var incidents = pm.response.json();
var count = incidents.length;
console.log(‘Retrying ’ + count + ’ instances…’);
for(var i=0; i < count ; i++){
var incident = incidents[i];
pm.sendRequest(
{
method: ‘DELETE’,
url: pm.variables.get(‘base-url’) + ‘/rest/incident/’ + incident.id
}, function(err, res){
console.log(res);
}
);
}

But I got this console result:
GET http://localhost/rest/incident?processDefinitionId=CheckoutWebFlow:3:0c1a0e90-334b-11eb-8c3b-5e93526b4bdc&activityId=UpdateCheckoutStatusAcceptedTask&maxResults=1200620 ms
Retrying 1 instances…
DELETE http://localhost/rest/incident/0a171d7c-54db-11eb-ae13-be347f09790a400152 ms
{id: “ff075c9b-50cc-4cf9-82c5-0206b244b49d”, status: “Bad Request”, code: 400…}

What is miss?

Hi @RodrigoCarlstrom,

Have a look at the response code documentation for the DELETE request: https://docs.camunda.org/manual/7.14/reference/rest/incident/resolve-incident/#response-codes. For incidents of type failedJob, you cannot resolve them with this method, but instead must set the job retries to a value > 0.

Cheers,
Thorben

Thanks for answering!

I set the script like this:
pm.sendRequest(
{
method: ‘PUT’,
url: pm.variables.get(‘base-url’) + ‘/rest/job/’ + incident.jobDefinitionId + ‘/retries’,
body: {
“retries”: 1
}
}, function(err, res){
console.log(res);
}
);

Gave this error:
{id: “ba578db3-f7fe-49c4-995c-7cb99f0b35cd”, status: “Internal Server Error”, code: 500…}

After this way:
pm.sendRequest(
{
method: ‘PUT’,
url: pm.variables.get(‘base-url’) + ‘/rest/job/’ + incident.jobDefinitionId + ‘/retries’,
body: “{“retries”:1}”
}, function(err, res){
console.log(res);
}
);

And this error:

  • {id: “dc480b83-11eb-4dd2-858d-fbc554685b7a”, status: “Unsupported Media Type”, code: 415…}

What would be the correct format?

Is the Content-Type header declared as application/json?

It worked, I adjusted the URL like this:
{{base-url}}/rest/job?processDefinitionId=CheckoutWebFlow:3:0c1a0e90-334b-11eb-8c3b-5e93526b4bdc&activityId=UpdateCheckoutStatusAcceptedTask&maxResults=1&withException=true

And the script looks like this:
var jobs = pm.response.json();
var count = jobs.length;
console.log(‘Retrying ’ + count + ’ instances…’);
for(var i=0; i < count ; i++){
var job = jobs[i];
pm.sendRequest(
{
method: ‘PUT’,
url: pm.variables.get(‘base-url’) + ‘/rest/job/’ + job.id + ‘/retries’,
header: ‘Content-Type: application/json’,
body: {
mode: ‘raw’,
raw: JSON.stringify({“retries”: 1})
}
}, function(err, res){
console.log(res);
}
);
}

Thank you Thorben!