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.
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.
The order of the requests - first request should be executed before the second request (which uses the getResponse from environment).
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.
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.
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!
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?
I had the same issue, setting delays didn’t work for me, in my case I was trying to do postman.setNextRequest function in POST request and simple validations on GET request. Went into the collection JSON and changed the order of execution. Made my GET request execute before POST, that fixed the problem for me.