Different behaviour in Collectionrunner vs. Newman

Hi all,

my general workflow (simplified) within a collection is:

  1. Create something
  2. Query certain things

Problem is, that creation sometimes fails, due to timeouts, environment not being available, you-name-it, so I want to give it a retry, especially when running the collections in Jenkins via newman.

So I came up with some Javascript in the testtab of my very first request:

if (!pm.environment.get("collection_tries")) {
    pm.environment.set("collection_tries", 1);
}
if ((pm.response.code != 201) && (pm.environment.get("collection_tries") < 3)) {
var tries = parseInt(pm.environment.get("collection_tries"), 10);
pm.environment.set("collection_tries", tries + 1);
     setTimeout(function() {}, 5000);
     postman.setNextRequest(request.name);
 } else {
     pm.environment.unset("collection_tries");
   // my tests
}

This is working perfectly fine in the Collectionrunner.
But when I execute it via Newman, I always get “500 URL Open error”.

Any ideas what is causing this?

Many thanks in advance,
Christian

PS.: How can I format that code example properly?! :-o

I am not sure your problem comes directly from your code.
Did you try using the htmlextra report and look into what was sent / received?

Maybe there is a variable in the URL / body that is not properly resolved.