Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The NULL values captured from previous URLs in Newman is not passing properly in next subsequent URL. #1339

Closed
anilsbs opened this issue Dec 12, 2017 · 5 comments

Comments

@anilsbs
Copy link

anilsbs commented Dec 12, 2017

Hi Team,
we are executed REST URL's using postman. The multiple REST URL's are collected and executed as part of a postman collection. All REST URL's are executed properly without any issue from postman collection console. The postman collection scripts ran from command console using Newman command and some of the REST URLs ran from command console using Newman are getting 400 HTTP error code (BAD REQUEST). The reason for this issue is NULL values captured from previous URLs response are captured in postman environment variables and Newman is not properly passing in next subsequent REST URL's. Kindly guide me on the same how to resolve it.

The Newman version is 3.8.2 and the node version is v6.11.3.

Please find the collection and environment files as attached by removed all sensitive details it.

The command/script used to run Newman is "newman run C:\hudson\NEW.postman_collection.json --delay-request 2000 -e C:\hudson\Test.postman_environment.json --export-environment C:\hudson\Test.postman_environment.json"

The issue here is
The value is captured in environment variable "paramater_B" is NULL value from REST URL 1 server response and this value should be passed to REST URL 2 payload data. In POSTMAN, the NULL value is passed properly and server will responded properly with 200 HTTP status code for REST URL 2. whereas the same collection ran from NEWMAN will return with 400 HTTP status code for REST URL 2.

So, if you hardcode the NULL value directly in payload of REST URL 2, will receive proper server response with HTTP status code 200 from NEWMAN.

Hence NULL values captured in environment variable is not passed properly in NEWMAN. Could you kindly guide us how to debug how the values are sent to server by NEWMAN.

Please let me know if you required more details to share.
PostMan scripts.zip

@prakharjoshi
Copy link
Contributor

@anilsbs In the request body for REST URL 2, you are using environment variable {{parameter_B}} without quotes. Can you try using environment variable with quotes?

Also, you should update the Newman version to 3.9.1.

@prakharjoshi prakharjoshi self-assigned this Dec 12, 2017
@anilsbs
Copy link
Author

anilsbs commented Dec 12, 2017

@prakharjoshi ,
Thank you for your kind response.
I tried environment variable with quotes and observed the same issue 400 HTTP status code.
if we use environment variable with quotes? the server will treat it as null string instead of null value right? So, we need to find how the newman is sending payload data package to web server and how to debug the same?

will verify it in Newman version to 3.9.1 as soon as possible.

@anilsbs
Copy link
Author

anilsbs commented Dec 12, 2017

@prakharjoshi , In the latest version we are getting the error as it is trying to convert the null to string. Please find the attached screenshot for details. But the same URL is working from PostMan with same payload.
newman execution error

@prakharjoshi
Copy link
Contributor

@anilsbs Apologies for the delay in reply, For debugging this can you log the value of paramater_B environment variable in pre-script of REST URL 2. Also, we will suggest you use new pm.* APIs in the sandbox.

Actually, the variables values should be stored as strings as mentioned here. So please check what is the value that you are getting while fetching parameter_B from env variable in pre-script.

@kunagpal
Copy link
Member

@anilsbs Closing issue due to inactivity, feel free to revert if you're facing difficulties 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants