Skip to main content
Solved

got 401 "Unauthorized" error when using Postman


Forum|alt.badge.img+5

I’m following the course instruction to use postman. However, after token is generated successfully, when use the genenrated token to call the API such as list asset, I got 401 "Unauthorized" error as follows 

{

    "error": {

        "code": 401,

        "message": "Unauthorized"

    }

}

 

The following is my env and auth settings

 

Best answer by Wei Wu

Right I dont have api-key under Headers section.

I double checked the list request, and it seems it does not recognize “{{project}}” env for some reason although it is defined together with other envs such as {{baseUrl}}.

So I replaced the {{project}} with “publichdata”, and it then works.

Thanks @Sofie Haug @Shashan Udawatte  for the suggestions.

 

View original
Did this topic help you find an answer to your question?

10 replies

Forum|alt.badge.img+1

Hi Wei, please make sure that under your Headers the Key api-key is unticked. 

 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • January 31, 2023

We don’t use API-keys in postman anymore! But Wei, double check that you have selected the correct environment (upper right corner) and that there are no extra spaces in the variables or current values :) 


Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • January 31, 2023

Also, when you are in the Authorization (under Cognite API v1) and have got the token, you also need to click save (upper right corner). An indication that something is not saved, is this orange dot on the tab that you see in my picture below. Please click save (the orange dot will disappear and then try to list assets again :) 

 


Forum|alt.badge.img+5
  • Author
  • Seasoned
  • 6 replies
  • Answer
  • January 31, 2023

Right I dont have api-key under Headers section.

I double checked the list request, and it seems it does not recognize “{{project}}” env for some reason although it is defined together with other envs such as {{baseUrl}}.

So I replaced the {{project}} with “publichdata”, and it then works.

Thanks @Sofie Haug @Shashan Udawatte  for the suggestions.

 


ChandC
Committed
Forum|alt.badge.img
  • Committed
  • 3 replies
  • June 9, 2023

 

 

Thanks @Wei Wu I observed the same behavior.   I was receiving an Unauthorized message until I replaced {{project}} with publicdata.


Muhammad
Committed
Forum|alt.badge.img+1
  • Committed
  • 7 replies
  • November 4, 2024

I have tried all the solutions above. Yet, I’m having the “401 unauthorize error” can anyone please help me resolve this issue. I have attached the error below.


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Muhammad can you please share screenshots of the authorization tab of the collection and the enviroment(please make sure to remove secrets when sharing). 


Muhammad
Committed
Forum|alt.badge.img+1
  • Committed
  • 7 replies
  • November 4, 2024

Thanks for the heads-up. I have tried the both ways it didn’t worked out. Below are the attached images.


Muhammad
Committed
Forum|alt.badge.img+1
  • Committed
  • 7 replies
  • November 7, 2024

Hi @Mithila Jayalath . can you please respond to the above problem.

Thanks 


Mithila Jayalath
Seasoned Practitioner
Forum|alt.badge.img

@Muhammad  It’s bit hard to troubleshoot your issue with the provided screenshots. I’ll create a support ticket for this issue and our support team will reach out and help you to resolve it.


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings