Collection runner is not executing the GET request when environment variable is appended in the URL but manually works fine

tests
collections
parse
setenvironmentvariab
runnercollection

#1

Hi,

There are 2 requests in collection: one is POST(I’m setting the environment variable
‘getResponse’ with the value I received from the response body) and another one is GET.

In GET request where I’m sending the URL by appending the global variable(getResponse) like “http://www.abc.com/{{getResponse}}”, when I execute it manually it gives me a response with 201 accepted status, and output in JSON format like below.

{
“id”: “d9c6”,
“reference”: “abcd”
}

But, when I run this request through collection runner I’m getting an error in parsing, gives me 555 error status code and response body is giving nothing but if I hard code the GET URL and run through collection runner it works fine.

Parsing code to get the ‘reference’ parameter from the response body:

let response1 = pm.response.json();
let reference = response1.reference;

Parsing is working fine if I execute the request manually.

Error getting is:

JSONError | No data, empty input at 1:1 ^

Please help!

Thanks in advance!
Shri


#2

When running the collection through the collection runner are you sure that you’re selecting the correct environment?

Environment selector in collection runner


#3

Yes, I’m selecting the correct environment. And, interesting thing is, if I hard code the URL manually and run through collection runner with proper environment if perfectly works.


#4

Couple of things to check:

  1. The order of the requests - first request should be executed before the second request (which uses the getResponse from environment).
  2. Check the value of the variable by writing console.log(pm.environment.get('getResponse')); in the pre-request script and check it in Postman Console if the correct value is showing up / not.
  3. Run the same collection with newman - if it fails to run in newman also then there is an issue with the collection itself.

If all of the above fail, kindly share the collection.
You can duplicate the collection, retract any sensitive information and share the URL for the cloned collection rather than your main collection.


#5

Hi @sivcan

I have checked all the above listed things, but still no luck. We have limitation to not provide collections outside. I will have a close look into the issue and will let you know if I get anything out of it.

Thanks for your help! :slight_smile:

I have another problem, can we connect to database through postman. We are using the mysql database, I have Host and Password? Can you please guide me how to proceed further? Do we need the separate database endpoint URL for accessing the database tables?


#6

You can read the thread which tells you why you can’t perform DB queries from Postman.


#7

Hey @sivcan

The problem was with the delay while running the collection runner. I was actually giving the min delay which was causing an issue.

Looking forward to learn more.

Thanks for your help!
Shri