Postman CLI_Collection Run_401 Unauthorized_ERROR

Using postman CLI in my Windows 10 PC

When using “postman collection run” command in Postman to run a collection run to GET accounts API keys thru Infobip’s API

Postman CLI, is not pulling data set (basic authentication & account Key data) from local file (PC folder/file) resulting in [401 Unauthorized, 358B, 913ms]

Here are the three command lines entered to Postman CLI:

postman login --with-api-key PMAK-XXXXXXXXX-XXXXXXXXXXXXXXX
postman collection run C:\API\IS/myCollectionFile_16r.json
postman collection run 7504733-c945fe0b-e7f8-4b70-b777-cd38f7933d47 -e 7504733-a794f7b8-a6af-4a13-8463-a35872365310

Here the collection run results:

Postman CLI run data uploaded to Postman Cloud successfully.
You can view the run data in Postman at: https://go.postman.co/workspace/901adea9-72a9-4809-8170-0d0159447eee/run/7504733-dff94caf-dece-4600-9318-10dc24fd7894

Please let me know what should I do in order to run this collection propertly thru Postman CLI

PD: Attached are several files/screenshots, among them the actual data set file

Cordially,

Adolfo Bejarano



Hey @postmmag :wave:

Welcome to the Postman community! :postman:

You attached an image of a JSON datafile which is called myCollection_16r but it’s not in the correct format to be able to use all of those values.

That’s not a collection so the second command isn’t running anything, as you can see in the summary table. I’m not sure what the expectation is there?

Are you trying to use the data from your local json file, on the run in the third command?

Hi Danny, good day. I hope you are doing well today Saturday.

Attached there are five screenshots that show the complete successful performance of my Run Collection thru Postman Desktop App.

Also one of the screenshots show the code I should use to run the same collection run thru Postman CLI.

So the only thing I think is wrong in order to have a successful result in Postman CLI is the json’s data set file format.

Your quote #1: “You attached an image of a JSON data file which is called myCollection_16r but it’s not in the correct format to be able to use all of those values.”

Please tell me what/how should be this json file format?

Your quote #2: “Are you trying to use the data from your local json file, on the run in the third command?”

My first aim is to have the same outcome/result I get when running this collection run in the Postman Desktop App, using the manually option.

My second and main aim is to collect thru Postman CLI, all the results/responses of my collection run 16 iterations in a file/jar/container.

Thanks for giving a hand on this one.

Cordially,

Adolfo B.

2023-09-02 ~ 07.49.45


Hi Danny, good day.

Thanks for your reply and seeing my case.

The datafile format should look similar to this:

[
    {
        "basicAuth": "ABC123"
    },
    {
        "basicAuth": "ABC456"
    }
]

Each object in the array, would be a iteration - This would resolve the {{basicAuth}} variable in your request, taking the next value each time.

Hi Danny, good day. Thanks for your response.

I do need to reference two different pair of variables for iteration: AccID & basicAuth

Therefore my json file should goes like this : ?

[
    {
        "basicAuth": "ABC123",
	"AccID": "1234"
    },
    {
        "basicAuth": "ABC456",
	"AccID": "5678"
    }
]

Hey @postmmag,

Yep, that would then pick up those values and resolve the variables for each iteration.

A post was split to a new topic: Postman CLI - Auth Issue With Requests