Expand my Community achievements bar.

SOLVED

How to Use POST Response from Alfresco API in AEM6.4

Avatar

Level 4

Dear all, Thanks for your response now it is resolved.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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.h...

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

 

View solution in original post

5 Replies

Avatar

Level 10

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

Avatar

Level 4

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.

Avatar

Correct answer by
Level 10

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.h...

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

 

Avatar

Level 10

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?