Not able to run my collection in CLI same is running functional

I need some help, My issue is my collections are running successfully in functional mode but same when i wan to run from CLI or Scheduled runs, my scripts are failing.

Its is giving "
[401 Unauthorized, 299B, 1809ms]

│ ‘Unexpected response:’, { message: ‘Una
│ uthorized’ }"

I need some help here.
Thanks,
Anil

Below is the CLI cmd I am using
Last login: Sun Sep 29 22:54:46 on ttys002

~ postman login --with-api-key {{postman-api-key-here}}

postman collection run 34170092-ba14e4b2-16cb-4fc6-9330-f695abd79ff7 -e 34170092-2ecd3dd7-d2ad-42b8-b756-9bf5098e563f -i 34170092-9949f173-db4a-48f7-9823-656889e0e4a0 -i 34170092-52a4fd01-e109-4f9b-9eb8-2cefac9decdf

When i verified my URL it is showing “com//cash” a double “//” I think it is causing the issue,
How do i fix this?

Hey @lunar-module-operato :wave:t2:

Which part of your Collection is setting the authorization for the requests? Are you running a script in a pre-request and store a variable?

Hi Danny,

Thank you for quick response,

We are passing Auth Type- bearerToken at Collection level and environment level, Yes we are running script in a pre-request and storing to variables.

thanks,
Anil.

Any suggestion @danny-dainton how to move forward

If you’re storing variables only in the current value, those are not synced and they wouldn’t be seen outside of your Postman instance.

The CLI wouldn’t be able to resolve the values as those are not available, they would need to be in the initial values for that to happen.

Variables set in a script during the execution of the Collection should carry through and will be used.

I don’t know the full configuration of what you have in front of you or the scripts that you’re using.

Thank you @danny-dainton , let me set my variables and set them to the initial values and give a try.

Hi @danny-dainton , when i checked my variables in environment files , both Initial and Current values are having the same values.
Is there any other constraints? where my scripts are failing in scheduler and passed in functionally.

I do have few pre requisite scripts which set some of these Env values during run time.

I’m kinda at a disadvantage as I cannot see what you have in front of you or what you have tried so far :pray:

Are you able to create a dummy Collection using the https://postman-echo.com/get endpoint and an environment file to test out the Postman CLI flows that you’re seeing.

Could you tried using the --verbose flag or add additional console logs to the request to see what’s not getting set through the workflow?

The scheduled runs would need that variables in the initial value in order to see these as they are run in the Cloud and not on your machine, same with the CLI.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.