Hello, I need to consume APIs using AEM, I know it is possible to do it using OSGI service but I can't find any documentation or tutorial showing how to do it. The idea is to use the API through Java, and pass it through a varival to the ui.frontend. Today I use MapTo to do this communication, it works really well.
Solved! Go to Solution.
Views
Replies
Total Likes
Generally, we prefer to call the APIs from FE, you can use a Dispatcher proxy to do that. Refer to this URL to understand why AEM is not preferred to use as a proxy to make API calls. https://cqdump.joerghoh.de/2024/06/27/do-not-use-aem-as-a-proxy-for-backend-calls/. If you still need to use it for implementing some business logic refer to this URL -https://kiransg.com/2021/11/08/aem-rest-service-using-http-client-factory/
Hi @ElvisRo ,
I am not sure why you have to call API thru java back-end, but by considering performance in mind, you should call the api from the front-end only.
Normally we keep api endpoints and credentials in a form of OSGI configuration and read it from there and pass it to front-end for for further execution.
To Configure OSGI please see the video
https://experienceleague.adobe.com/en/docs/experience-manager-learn/cloud-service/developing/basics/...
If you are using AEM as cloud service you can take help from Environment variable as well if it suites your requirement.
Hope this helps
Umesh Thakur
I intend to keep the call only on the Front-end, but I had already seen recommendations for OSGi.
So I won't get blocked by something from AEM if I do this on the front-end in ui.front-end, right?
You can make call from OSGI service that is totally fine but keep in mind, back-end call is expensive.
is it possible to share the recommendations or the exact meaning of OSGI, you are referring to?
Generally, we prefer to call the APIs from FE, you can use a Dispatcher proxy to do that. Refer to this URL to understand why AEM is not preferred to use as a proxy to make API calls. https://cqdump.joerghoh.de/2024/06/27/do-not-use-aem-as-a-proxy-for-backend-calls/. If you still need to use it for implementing some business logic refer to this URL -https://kiransg.com/2021/11/08/aem-rest-service-using-http-client-factory/
@ElvisRo Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies