How to Use POST Response from Alfresco API in AEM6.4 | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Gaurav-Behl

In your scenario,  POSTMAN is replaced by AEM to access the API endpoint, hence you may not need  -- post.setHeader("Postman-Token", "xxxx");

 

You may go through following links to set up OAuth. There are a lot of articles available on AEM-OAuth integration in this forum and on web:

https://helpx.adobe.com/experience-manager/kt/eseminars/gems/aem-oauth-server-functionality-in-aem.html

https://aemcorner.com/adobe-granite-oauth-authentication-handler/

 

5 replies

Gaurav-Behl
Level 10
August 29, 2019

I'm unable to understand why do you want to pass postman-token in this request.

For bearer token try this --   

post.setHeader("Authorization", "Bearer " + token); 

or

httpClient.DefaultRequestHeaders.Authorization =
  
new AuthenticationHeaderValue("Bearer", "Your Oauth token");

For passing json, you have already written the code to set the body/json in HttpEntity -- post.setEntity(requestEntity);

Level 4
August 29, 2019

Dear Gaurav,

 

Thanks a lot for your reply. Please see my comments in below.

 

I'm unable to understand why do you want to pass postman-token in this request.

 

My requirement is that I need all cm:title from Alfresco APIthrough post request in AEM and show in the AEM page through component.

 

In Postman I am posting request and getting response while passing below in body.

 

 

 

In Postman I am using authorization as Bearer Token.

 

I am not sure if I need to use that token "or" not in AEM. Also that token is expired in every 1 hr. I think we need that token in AEM , because the API is not public one . To get/post request for API we should use oauth token.

 

Please suggest.

 

Thanks a lot.

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
August 29, 2019

In your scenario,  POSTMAN is replaced by AEM to access the API endpoint, hence you may not need  -- post.setHeader("Postman-Token", "xxxx");

 

You may go through following links to set up OAuth. There are a lot of articles available on AEM-OAuth integration in this forum and on web:

https://helpx.adobe.com/experience-manager/kt/eseminars/gems/aem-oauth-server-functionality-in-aem.html

https://aemcorner.com/adobe-granite-oauth-authentication-handler/

 

Level 4
September 3, 2019

Thanks , it is resolved now.

Gaurav-Behl
Level 10
September 3, 2019

Enable/Configure debug logs on "com.sunita.wpr.aem", "org.apache.http" and "org.apache.sling"  and check

Do you see this servlet/service registered and enabled in felix console?

What do you see in the browser console logs?  Use developer tools or Fiddler or any other proxy and check the headers on request/response

Check if there are any errors related to CORS/CSRF/Referrer Filter?