Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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

Avatar

Avatar
Boost 1
Level 1
madhavimaheshwari
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
madhavimaheshwari
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
madhavimaheshwari
Level 1

27-04-2021

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.

madhavimaheshwari_0-1619584751808.png

 

Accepted Solutions (0)

Answers (4)

Answers (4)

Avatar

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

367 likes

Total Posts

462 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

367 likes

Total Posts

462 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile
asutosh_jena
Level 10

27-04-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.

 

asutosh_jena_0-1619538911518.png

 

Thanks!

Avatar

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

367 likes

Total Posts

462 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

367 likes

Total Posts

462 posts

Correct Reply

134 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile
asutosh_jena
Level 10

May 04, 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.

asutosh_jena_0-1620197631516.png

 

Avatar

Avatar
Boost 1
Level 1
madhavimaheshwari
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
madhavimaheshwari
Level 1

Like

1 like

Total Posts

5 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
madhavimaheshwari
Level 1

May 04, 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?

 

Avatar

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

240 likes

Total Posts

253 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

240 likes

Total Posts

253 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
Nikhil-Kumar
MVP

28-04-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?