and after that another POST that changes the status of the asset to NOT-DAMNED (it is a job that takes around 3 mins). I want to be able to poll it for when the status becomes NOT-DAMNED, so hitting the API every 30 sec to check if the status is NOT-DAMNED
This should do the trick:
const response = pm.response.json();
However I am looking for something to break my loop if it never becomes “NOT-DAMNED”. Anyone can help with that. Tried to save counter in an environment variable but maybe am too stupid to write that script by myself
If I’m not mistaken, “status” is not a “response” property but a “pm.response” property.
I’ve followed an Udemy course about postman where the instructor always use the same const response = pm.response.json();.
I think this is a very bad practice because it is not a response but the data of a reponse.
I recommand you to change to “respData” or “jsonData”…
(“data” seems to be used by postman when you use a csv file, and represents a line, so, I don’t use it)
Hope this helps…
Best
Didier
EDIT: this post was in the top of the list, I did not see it was one year old… maybe it could help someone else
response.status is perfectly valid consider the original posters example response.
Status is a key in that response.
Not to be confused with the status on a assertion which is a function from Postman to help assert status codes.
pm.expect(response).to.have.status(200)
Two completely separate things.
To answer the original posters question.
Indefinite loops are a bad thing, so you would check for the NON-DAMNED status and a configurable counter object with the counter being the trigger that prevents the indefinite loop.
I can create an example, but as this is over a year old, I’m only going to do that if someone wants it (or I’ll just point to relevant questions on Stack Overflow as there are a bunch of questions related to best practice for loops on there).