AEM 6.4 form submission to Rest endpoint via sling servlet | Community
Skip to main content
Level 3
Dec 3, 2019 6:28 PM UTC
Solved

AEM 6.4 form submission to Rest endpoint via sling servlet

Scenario :

Adaptive Form-1

Dropdown(Year - Example 2018, 2019, 2020)

Dropdown(TYPE - Example AAA, BBB, CCC)

Create button

Adaptive Form-2

Label(Display form# example AAA-2018-10000)

Requirement:

On click of create button in Form-1, we have to call AEM servlet(pass Year and Type values in Query Params) which in turn invokes third party endpoint and return form# based on user dropdown selection(Year and Type) in Form-1.

Once the response code is 200 from third party end point, we have to redirect to form-2 which displays form# as label.

Please note that AEM servlet will send GET/POST request to third party endpoint and get the response. We should not call the third party endpoint directly from form submission.

Analysis

I tried to invoke AEM servlet using Submit To Rest Endpoint by adding servlet URL into URL for Post request field. However in logs, it is showing as Unauthorized 401 while calling AEM servlet. Please let me know how to implement this requirement.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
workflowuserAccepted solution
Employee
Dec 3, 2019 10:00 PM UTC

when you are calling the servlet in AEM from your form submission, you can add the servlet as shown here from the localhost:4502/system/console/configMgr. Search for Adobe Granite CSRF Filter and add your servlet path in the excluded Paths

4 replies

Level 3
Dec 29, 2019 12:07 PM UTC
This scenario is working on AEM publish not on AEM author.
Translate
guyh59060666
New Participant
Dec 17, 2019 5:30 AM UTC

Hi Sankar,

Did you find a solution to the problem?

Translate
Employee
Dec 3, 2019 10:02 PM UTC

make sure you are able to call the aem servlet from postman

Translate
workflowuserAccepted solution
Employee
Dec 3, 2019 10:00 PM UTC

when you are calling the servlet in AEM from your form submission, you can add the servlet as shown here from the localhost:4502/system/console/configMgr. Search for Adobe Granite CSRF Filter and add your servlet path in the excluded Paths

Translate