Test script in newman failed, but all success in postman for 30 day challenge postman for developer

I currently running “30 Day postman challenge for developer” on task day 13,
all the test case are “pass” also with the submit folder

but the same collection failed only in submit folder, which the first test return “401 Unauthorized”, the other 3 return “TypeError cannot read info”

I’ve tried to follow solution similar to my question, which to add the environment variable to the newman run script ‘–env-var =’, but this doesn’t fix the issue…

could anyone please tell me what happened here?

Hi @telecoms-astronaut-1

What is the newman command you are running in CMD?

You are getting a 401 unauthorised error, I suspect this is because you are not passing the API key with the run command.

You may need to do some research on this one. There’s many ways to handle sensitive information locally while running Newman, but be careful not to expose your secrets in your public workspace.

^^ In the client when you run it should be grabbing the API key you have set from the “current” variables column. For security reasons this column is not exported.

You would need to pass the API key into the run command;

--env-var "postman_api_key=[api-key-value]"
1 Like

Hi, this is the newman command I run before

newman run "Day 13- Newman.postman_collection.json" --env-var "collectionUid=myCollectionUid" 

yup, your suggestion actually fix only the first issue with 401 unauthorized, but I still got 3 errors saying “cannot read info”, which this info is the key from response body

here, the info is just capturing the field from response

and it pass in client postman

and apparently I need to passed the collectionUid also to the newman command XD

Thank you, this case can be closed

1 Like