Unexpected token 'U' at 1:1 Unauthorized request using Newman Unauthorized request

My question:
I got “token ‘U’ at 1:1 Unauthorized request” when I use Newman to run my collection.
JSONError Unexpected token ‘U’ at 1:1
Unauthorized request
^
Details (like screenshots):

How I found the problem:

  • Run collection via Newman

I’ve already tried:

  • Run collection in Postman console

Hi @CathyWang

This may not completely resolve the issue but if you are going to use the “long notation” I think you are missing a - from “environment”.

Should be either -e or --environment (Note the 2x - for the latter)

More info here;

I’m not 100% sure if you can call variables from a file you are also trying to load at the same time… but if you try the dash thing above first and report back, I will look into this further if needed. :upside_down_face:

Thank you for the response!
Yes, I did use --environment in the command. I didn’t call variables from a file. I just set the environment variables and got the environment URI from: https://api.getpostman.com/environments?apikey=$apiKey.

Regards,
Cathy

When you run this command;

$ newman run “[https://api.getpostman.com/collections/$uid?apikey=$apiKey](https://api.getpostman.com/collections/%24uid?apikey=%24apiKey)”
–environment “[https://api.getpostman.com/environments/$uid?apikey=$apiKey](https://api.getpostman.com/environments/%24uid?apikey=%24apiKey)”

Where are the values for $uid and $apiKey stored?

I got the uid for collections from https://api.getpostman.com/collections?apikey=$apiKey
I got the URI for environment from https://api.getpostman.com/environments?apikey=$apiKey
I created the apiKey in Postman.

I just passed the above value to the newman command line. Where these values should be stored?

Thanks,
Cathy