# Postman CLI\_Collection Run\_401 Unauthorized\_ERROR

**URL:** <https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286>\
**Category:** Help Hub\
**Tags:** authentication, postmancli\
**Created:** [September 2, 2023, 2:08am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286 "2023-09-02T02:08:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![postmmag](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@postmmag](https://community.postman.com/u/postmmag)\
**Post date:** [September 2, 2023, 2:08am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/1 "2023-09-02T02:08:18Z")

</div>

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:

```auto
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](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

 ![2023-09-01 ~ 20.26.52](https://us1.discourse-cdn.com/getpostman/original/3X/0/a/0abb3dda0c2ee774b8c0786b91ee642cb4468ce5.jpeg)  
 ![2023-09-01 ~ 20.28.26](https://us1.discourse-cdn.com/getpostman/original/3X/0/f/0fed407be2b5454e6f360ae8d20a02cdc168b635.jpeg)  
 ![2023-09-01 ~ 21.06.27](https://us1.discourse-cdn.com/getpostman/original/3X/8/9/8971288c6e2e3aa50b1351215efd1935d848695b.jpeg)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 2, 2023, 8:59am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/2 "2023-09-02T08:59:40Z")

</div>

Hey @postmmag 👋

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?

---

<div class="post-metadata">

**Author:** ![postmmag](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@postmmag](https://community.postman.com/u/postmmag)\
**Post date:** [September 2, 2023, 1:28pm UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/3 "2023-09-02T13:28:38Z")

</div>

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](https://us1.discourse-cdn.com/getpostman/original/3X/0/4/0418696fd43e06bc60b24bdf26eea340c12dc865.jpeg)

 ![2023-09-02 ~ 07.53.43](https://us1.discourse-cdn.com/getpostman/original/3X/3/b/3b2420ab386b84db3674f9fe3e523942fb802869.jpeg)  
 ![2023-09-02 ~ 08.08.45](https://us1.discourse-cdn.com/getpostman/original/3X/b/6/b6c535efdbcf309042ca5da8065d1a86a75c8325.jpeg)

---

<div class="post-metadata">

**Author:** ![postmmag](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@postmmag](https://community.postman.com/u/postmmag)\
**Post date:** [September 2, 2023, 1:52pm UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/4 "2023-09-02T13:52:35Z")

</div>

Hi Danny, good day.

Thanks for your reply and seeing my case.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 4, 2023, 10:05am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/5 "2023-09-04T10:05:07Z")

</div>

The datafile format should look similar to this:

```json
[
    {
        "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.

---

<div class="post-metadata">

**Author:** ![postmmag](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@postmmag](https://community.postman.com/u/postmmag)\
**Post date:** [September 4, 2023, 11:12am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/6 "2023-09-04T11:12:56Z")

</div>

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 : ?

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

```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 4, 2023, 11:15am UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/7 "2023-09-04T11:15:13Z")

</div>

Hey @postmmag,

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 26, 2023, 6:30pm UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/8 "2023-09-26T18:30:43Z")

</div>

A post was split to a new topic: [Postman CLI - Auth Issue With Requests](https://community.postman.com/t/postman-cli-auth-issue-with-requests/52440)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 26, 2023, 6:30pm UTC](https://community.postman.com/t/postman-cli-collection-run-401-unauthorized-error/51286/9 "2023-09-26T18:30:59Z")

</div>


