I have made this collection to delete a bunch of jobs in our software,
https://www.postman.com/agi-admin/workspace/postman-community/collection/26232016-2db11d96-abc4-4a42-bd79-2379a98c09c5?action=share&creator=26232016
Most of the calls return 201 Created
but there are many that return 422 Unprocessable Entry
with a Body such as:
{
"errorType": "Unprocessable Entity",
"httpCode": 422,
"message": "Invalid options. Can't delete this job (418) because it has active children. Job Ids: 1841"
}
At this point, I have to:
- Manually go through the list of
422
responses. - Copy the list of child
job Id
’s mentioned at the end ofmessage
into a second copy of this collection’s Pre-request Script’sjobArray[]
and run that collection. Sometimes there are more422
responses with childjobId
’s there, and so a third collection needs to be made to delete thosejobId
’s, and so on. - Put the
jobId
’s that couldn’t be deleted, shown in parenthesis inmessage
, into the Pre-request Script’sjobArray[]
and re-run the collection so they can finally get deleted.
I’m fairly certain this could be automated much better by adding some code to the “Tests” page, so that’s what I’ll be working on but in the meantime will appreciate anything you all can offer or contribute as well.
𝒯𝒽𝒶𝓃𝓀 𝒴ℴ𝓊