Sling GET servlet | Community
Skip to main content
New Participant
March 20, 2017
Solved

Sling GET servlet

  • March 20, 2017
  • 4 replies
  • 2485 views

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.

4 replies

piotrkot
piotrkotAccepted solution
New Participant
March 23, 2017
rish_royAuthor
New Participant
March 22, 2017

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

kautuk_sahni
Employee
March 21, 2017

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

Kautuk Sahni
Prince_Shivhare
New Participant
March 20, 2017

Hi Rish,

Have you checked the below link:

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

~ Prince