Why I am getting Status 401 in response of an API request? | Community
Skip to main content
Level 2
April 27, 2021

Why I am getting Status 401 in response of an API request?

  • April 27, 2021
  • 4 replies
  • 9071 views

I am using a sandbox environment for aem. I want to use rest API of AEM and while using them on chrome browser I am getting a json response but while using those APIs in postman I am getting status 401 Unauthorized in response and body part of response is blank. In response headers I am getting  www-authenticate header as Basic realm="Sling (Development)". I have matched username and password in authorization parameter that is correct.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Asutosh_Jena_
Community Advisor
Community Advisor
April 27, 2021

Hi @madhavimaheshwari 

 

While making the request from postman you need to select Authorization type as "Basic Auth" and need to pass the username and password. Once you pass these information and make the request it will return 200 response and will no more give 401.

 

 

Thanks!

Level 2
April 28, 2021

Hi @asutosh_jena_ . I am doing that and username and passwords are also correct but still it is showing Status 401

 

Nikhil-Kumar
Community Advisor
Community Advisor
April 28, 2021

@madhavimaheshwari - I think the authorization issue is because of the login creds but if you are already providing that can you try adding the content type as JSON and try hitting it again?

Level 2
April 28, 2021

Hi @nikhil-kumar

I am doing that but still issue persists.

 

Can we have a quick connect to solve this issue?

Level 2
May 5, 2021

I am still stuck with the same issue. We have tried all the possible ways as suggested in some of the answers but still facing the same issue. Can anyone please help?

 

Asutosh_Jena_
Community Advisor
Community Advisor
May 5, 2021

Hi @madhavimaheshwari 

I see you are making a GET call while passing the credentials. You need to make the POST call and it will resolve the issue.

The same thing i have mentioned earlier in my above post as well.

Asutosh_Jena_
Community Advisor
Community Advisor
May 5, 2021

HI @madhavimaheshwari 

 

Try with only the below parameters with GET request. select Authorization type as "Basic Auth" and provide the credentials.

remove www-authenticate header.