Redirecting a Healthcheck endpoint to REST endpoint with query params | Community
Skip to main content
Level 3
March 21, 2025
Solved

Redirecting a Healthcheck endpoint to REST endpoint with query params

  • March 21, 2025
  • 2 replies
  • 420 views

Hi all,

 

We have some prefill services running on our AEM stack, we want to check the server health by prefilling a sample template with just a field. This service is a REST endpoint and the we make GET requests to it. I was trying to setup a dispatcher redirect

something like 

 

RewriteRule /healthcheck /bin/servlet/?json_input={"metadata": {"fillable": true},"envelope": {"actions": {"action": {"id": "1234","formid": "108646","formversion": "00","form_data": {}}}}}

Tried some flags that prevent encoding [NE], [QSA] with no luck, the chars still get encoded.

Any help would be greatly appreciated.

Thanks,

Abhishek

Best answer by Asutosh_Jena_

Hi @kolluax 

If I understand your requirement correctly, you want to rewrite the `/healthcheck` URL to call the servlet `/bin/servlet` and pass JSON data. Please confirm if my understanding is accurate.

If this is the case, Apache's `RewriteRule` does not support sending JSON payloads directly. You would need to either encode the JSON string and pass it in the URL i.e., something like:

RewriteRule ^healthcheck$ /bin/servlet/?json_input=%7B%22metadata%22%3A%7B%22fillable%22%3Atrue%7D%2C%22envelope%22%3A%7B%22actions%22%3A%7B%22action%22%3A%7B%22id%22%3A%221234%22%2C%22formid%22%3A%22108646%22%2C%22formversion%22%3A%2200%22%2C%22form_data%22%3A%7B%7D%7D%7D%7D%7D [L,QSA]

Or, If the servlet accepts POST request, you need to pass the JSON data in request body.

Thanks,

Asutosh Jena

2 replies

Asutosh_Jena_
Community Advisor
Asutosh_Jena_Community AdvisorAccepted solution
Community Advisor
March 21, 2025

Hi @kolluax 

If I understand your requirement correctly, you want to rewrite the `/healthcheck` URL to call the servlet `/bin/servlet` and pass JSON data. Please confirm if my understanding is accurate.

If this is the case, Apache's `RewriteRule` does not support sending JSON payloads directly. You would need to either encode the JSON string and pass it in the URL i.e., something like:

RewriteRule ^healthcheck$ /bin/servlet/?json_input=%7B%22metadata%22%3A%7B%22fillable%22%3Atrue%7D%2C%22envelope%22%3A%7B%22actions%22%3A%7B%22action%22%3A%7B%22id%22%3A%221234%22%2C%22formid%22%3A%22108646%22%2C%22formversion%22%3A%2200%22%2C%22form_data%22%3A%7B%7D%7D%7D%7D%7D [L,QSA]

Or, If the servlet accepts POST request, you need to pass the JSON data in request body.

Thanks,

Asutosh Jena

kautuk_sahni
Community Manager
Community Manager
April 10, 2025

@kolluax Did you find the suggestion helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni