Solved

got 401 "Unauthorized" error when using Postman

  • 31 January 2023
  • 5 replies
  • 171 views

Badge +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

 

icon

Best answer by Wei Wu 31 January 2023, 19:45

View original

5 replies

Userlevel 1
Badge +1

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

 

Userlevel 3
Badge +6

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

Userlevel 3
Badge +6

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

 

Badge +5

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.

 

Badge

 

 

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

Reply