Skip to main content
Jan 8, 2016 2:16 PM UTC
Solved

Creating REST web service in cq5

Hi I want to create a REST web service which will return a json object

How can i do this in CQ?

Please guide me

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jan 22, 2016 11:20 PM UTC

Write a custom AEM Sling Servlet and use JSON data object to build JSON data. See this AEM Community article:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Once you have installed the OSGi bundle - other clients can invoke it using HTTP requests. 

Here is a brand new article that shows you how you can read the JCR and then convert JCR data into JSON. THis is a technique that you should know about as an AEM developer. 

https://helpx.adobe.com/experience-manager/using/quiz.html

Simply using a JSON extension on a AEM URL is not going to give you the precise JSON data that you most likely want. Its better to write app logic in an OSGi bundle that will create JSON you need. 

2 replies

Sham_HC
Level 10
Jan 8, 2016 7:17 PM UTC

   What is your use case?   By default aem is rest based & you can get json object by adding extension json however it might not work for modfying. Looking into OOB classic project task ui. It is rest web service with json for retreiva;/modification/deletion.

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Jan 22, 2016 11:20 PM UTC

Write a custom AEM Sling Servlet and use JSON data object to build JSON data. See this AEM Community article:

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Once you have installed the OSGi bundle - other clients can invoke it using HTTP requests. 

Here is a brand new article that shows you how you can read the JCR and then convert JCR data into JSON. THis is a technique that you should know about as an AEM developer. 

https://helpx.adobe.com/experience-manager/using/quiz.html

Simply using a JSON extension on a AEM URL is not going to give you the precise JSON data that you most likely want. Its better to write app logic in an OSGi bundle that will create JSON you need. 

Translate