Flows - send request - repeat request fails silently

i have a series of requests that i am using ‘flows’ to orchestrate.

each request kicks off a job elsewhere, and what i need to do is wait until the job kicked off from the request is complete until i move onto the next request.

after each request, i need to wait until the status returned is a certain value. i am trying to wait for the correct status by making another call to get the status every 3 seconds.

however when the flow is directed back to the send request to get the status, the flow ends and the request isnt made. there are no errors.

Postman for Windows

Version10.18.11
UI version
10.18.11-ui-231003-1330
Desktop platform version
10.18.10
Architecture
x64
OS platform
win32 10.0.19045

Hey @cbarrydcg

Welcome to the Postman community! :postman:

This sounds like something @lunar-module-geosci1 might be able help with :pray:t2:

1 Like

Seeing the entire flow might help diagnose this better. We suspect what’s happening here is that variables do not currently work as you might expect. They are read once. So if a variable is not defined repeatedly but feeds into a loop, the execution will halt. Are you able to share the entire flow? You can send me a private message so we can dig into this.

hi. thanks for getting back.

re-using the variable for the second time results in a halt… i am a little confused how i missed this in the documentation. is there somewhere you can point me to where i could find more on that behavior?

the 2nd evaluate block, the one after the if block, reads the variable for the 2nd time. the halt doesn’t come until the request block after the 2nd evaluate.

in any case i would expect an error of some kind to alert the user of the limitation.

i was able to work around this issue by building in the below in the test section of the status call.

var jsonData = pm.response.json();

function sendSameRequest() {
    var url = pm.request.url.toString();
    var headers = pm.request.headers.toObject();

    pm.sendRequest({ url: url, method: 'GET', header: headers }, function (err, response) {
        var responseJson = response.json();
        var retryCount = pm.environment.get("retryCount") || 0;
        retryCount++;

        if (responseJson.status !== 2) {
            if (retryCount < 18) {
                pm.environment.set("retryCount", retryCount);
                setTimeout(sendSameRequest, 10000);
            } else {
                pm.environment.unset("retryCount");
            }
        } else {
            pm.environment.unset("retryCount");

            pm.test("category count equals calculated count", function () {
                pm.expect(responseJson.categoryCount).to.eql(responseJson.calculatedCount);
            });

            pm.test("status is 2", function () {
                pm.expect(responseJson.status).to.eql(2);
            });
        }
    });
}

if (jsonData.status !== 2) {
    sendSameRequest();
}

I have the same problem as the OP where I can only read a variable once. How can you set a variable in a flow so it can be read more than once without resorting to writing a test script?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.