# Unable to run CLI - the Postman server returned status code: 401

**URL:** <https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721>\
**Category:** Help Hub\
**Tags:** cli, api-key\
**Created:** [November 12, 2025, 6:08pm UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721 "2025-11-12T18:08:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnDT](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@johnDT](https://community.postman.com/u/johnDT)\
**Post date:** [November 12, 2025, 6:08pm UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721/1 "2025-11-12T18:08:09Z")

</div>

In Azure DevOps, We started getting this error when running our tests in the CLI Pipeline.  
I have changed the api-key and set it to never expire.

I am still getting a 401. Nothing has changed outside of the collection

---

<div class="post-metadata">

**Author:** ![stryderhiryu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/stryderhiryu/32/34043_2.png) [@stryderhiryu](https://community.postman.com/u/stryderhiryu)\
**Post date:** [November 13, 2025, 12:41am UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721/2 "2025-11-13T00:41:56Z")

</div>

Make sure the variable that stores your API key is actually being passed into the Postman CLI step. It’s pretty common for a renamed variable to get skipped after updating a secret.

Also check that the collection and environment running in the pipeline are the same ones you tested locally. If you’re using Postman CLI, try printing or logging the variable in a pre-request script (just don’t show the full value) to confirm it’s being read correctly.

---

<div class="post-metadata">

**Author:** ![johnDT](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@johnDT](https://community.postman.com/u/johnDT)\
**Post date:** [November 13, 2025, 8:34pm UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721/3 "2025-11-13T20:34:25Z")

</div>

ok it I found the problem. it’s the way I’m trying to pull the global collection and it looks like this method doesn’t work anymore.

postman collection run “[collectionUUID]” -e “[environmentUUID]” -g “[https://api.getpostman.com/workspaces/[workspaceUUID]/global-variables?apikey=$(POSTMAN\_API\_KEY)](https://api.getpostman.com/workspaces/%5BworkspaceUUID%5D/global-variables?apikey=$(POSTMAN_API_KEY))” --ignore-redirects --delay-request 1000

Do you have any suggestions on how to get the global-variables?

---

<div class="post-metadata">

**Author:** ![stryderhiryu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/stryderhiryu/32/34043_2.png) [@stryderhiryu](https://community.postman.com/u/stryderhiryu)\
**Post date:** [November 13, 2025, 11:47pm UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721/4 "2025-11-13T23:47:36Z")

</div>

Try adding a script step before running Postman CLI.

Try

(Download globals to a file)

curl -s -H “X-Api-Key: $POSTMAN\_API\_KEY”  
[https://api.getpostman.com/workspaces//global-variables](https://api.getpostman.com/workspaces//global-variables)  
-o globals.json

(Pass the file to Postman CLI)

postman collection run “”  
-e “”  
-g “globals.json”

---

<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:** [November 17, 2025, 2:47pm UTC](https://community.postman.com/t/unable-to-run-cli-the-postman-server-returned-status-code-401/86721/5 "2025-11-17T14:47:24Z")

</div>

Hey @johnDT

Could you try using the `global-variables` endpoint again with the Postman CLI to see if that’s working again?

We reverted a change on our side and I wanted to check. 🙏
