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.
šÆš½š¶šš š“ā“š