Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Http POST not getting call

shishira_Pradha
Level 2
Level 2

I have written sling servlet for POST and I called through ajax and Chrome Rest Client , but it giving the 403 forbidden error, and i went through some search and find solution that need to remove the POST method from "Apache Sling Referrer Filter" and "CSRF Filter" in configuration Manager. I did same thing and it worked.

But same code is working for my friend without removing POST in configMgr,

Can you please answer what exactly issue with http POST in AEM ?

Both are using AEM 6.2

1 Accepted Solution
smacdonald2008
Correct answer by
Level 10
Level 10

To successfully post to an AEM servlet using AJAX - you need to use the AEM version of JQuery. This has a token that lets you perform a POST operation.

See:

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

in this article - notice we use:

 <cq:includeClientLib categories="cq.jquery" />

View solution in original post

11 Replies
smacdonald2008
Correct answer by
Level 10
Level 10

To successfully post to an AEM servlet using AJAX - you need to use the AEM version of JQuery. This has a token that lets you perform a POST operation.

See:

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

in this article - notice we use:

 <cq:includeClientLib categories="cq.jquery" />

View solution in original post

shishira_Pradha
Level 2
Level 2

Thanks Scott, It's working with AEM version of JQuery.

Regards,

Shishira

a_mn1
Level 4
Level 4

Hello Scott. Is using cq.Jquery the only recommended approach for doing POST call in AEM.  I have a requirement to write a sling servlet which supports POST request. I am looking for an alternative to using cq.Jquery to invoke the servlet.

Thanks,

Anand MN

edubey
Level 10
Level 10

Hi,

The reason cq.Jquery is recommended way because it gets the CSRF-Token from AEM which you need to pass in POST request.

If you still do not want to use cq.jquery refer this Send a CSRF Token to an AEM 6.1 Servlet without using jQuery or granite.csrf.standalone clientlib Ex...

Thanks

a_mn1
Level 4
Level 4

Why I dont want cq.Jquery is because the request will not be coming from my site. It could be a 3rd party web app.

Thanks,

Anand MN

viveksachdeva
Level 7
Level 7

I think you'll need to change Sling Referrer Settings to allow request from 3rd party app..

a_mn1
Level 4
Level 4

But , is that recommended approach for a production env?.

viveksachdeva
Level 7
Level 7

You are checking this on author, right? You are right that not recommended on prod.. It can be used for checking things on local/staging

Setting Your Referrer Filter to Allow Empty

a_mn1
Level 4
Level 4

I am looking for a recommended approach on prod publisher. I am aware of this testing approach in author.

Thanks,

Anand MN

a_mn1
Level 4
Level 4

Hi All, Any pointers to this?.Or is it that AEM by design doesn't support POST operation.

Regards,

Anand MN