Skip to main content
Mar 20, 2017 10:26 AM UTC
Solved

Sling GET servlet

Hi All,

Can someone share the example of How to write the REST API GET method in AEM where data can be shared in the form of  JSON when any client make the rest api call .

thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
piotrkot
piotrkotAccepted solution
Mar 23, 2017 11:34 AM UTC

4 replies

Prince_Shivhare
Community Advisor
Community Advisor
Mar 20, 2017 10:39 AM UTC

Hi Rish,

Have you checked the below link:

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

~ Prince

Translate
kautuk_sahni
Level 9
Mar 21, 2017 8:16 AM UTC

Hi 

To write REST Get/post method, you need to create a JAVA Sling Servlet.

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

// Here is the example for this.

Package :- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets/_jcr_content/main-pars/download_859830037/file.res/slingservlet6_2_client-1.0.zip

Here we are submitting data to POST method via AJAX call:-

$.ajax({
         type: 'POST',   
         url:'/bin/mySearchServlet',
         data:'id='+ claimId+'&firstName='+ myFirst+'&lastName='+ myLast+'&address='+ address+'&cat='+ cat+'&state='+ state+'&details='+ details+'&date='+ date+'&city='+ city,
         success: function(msg){
           alert(msg); //display the data returned by the servlet
         }
     });

Here URL is the path for request.

 

If you want to integrate or invoke 3rd party restful web service, see this

Link:- https://helpx.adobe.com/experience-manager/using/restful-services.html

// Creating Adobe Experience Manager bundles that invoke third party Restful web services

I hope this would help you.

~kautuk

Translate
Kautuk Sahni
rish_royAuthor
Mar 22, 2017 1:20 PM UTC

Hi kautuk,

Can you share the example of custom JAVA Sling Servlet using the GET method where the data is entered by the author using the classic dialog is return in json format when the rest api get method request is made.

thanks

Translate
piotrkot
piotrkotAccepted solution
Mar 23, 2017 11:34 AM UTC