Expand my Community achievements bar.

SOLVED

Submit to a Rest EndPoint

Avatar

Level 2

Hi,

I am evaluating the OOTB Form Template and Components for a requirement for a client.

We have to submit the Form to a Third Party REST API. We have no need to save the form data in AEM or any other persistent system.

What i have observed is if I configure the REST Endpoint in the Submit  action, the request first comes to AEM and then goes to a third party.

Is this the expected behavior?

Can i not send the Form Data directly to a third party API?

Regards,

Manas

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi Manas,

You can do an ajax call to service endpoint from javascript or jquery or any library of your choice. But if you want to do something structural. Then you call the endpoint from Sling Models and map the response from the endpoint some Sling Models and use it via sightly(This might be useful in GET request). For post, put and delete I don't think you need extra AEM layer for external service endpoint its an option. Like if you want to hide your external endpoint url or something then you can use the AEM layer.

~susheel

View solution in original post

5 Replies

Avatar

Administrator

mandeepgandhi any help here?

~kautuk



Kautuk Sahni

Avatar

Level 10

The best way is to write a custom form action that will send the Form data to an OSGi service. See:

Adobe Experience Manager Help | Creating a custom action for an Adobe Experience Manager Form compon...

Once you get the data to a Java service - you can invoke a third party REST Service using HTTP Java APIs.

See:

Adobe Experience Manager Help | Creating Adobe Experience Manager bundles that invoke third party Re...

This would be the best way to address your requirements.

Avatar

Level 2

Thanks smacdonald2008.

I already went through those links.

But my question is slightly different.

In case i DO need to send something directly to an End Point, Do i still need to go via AEM?

I am thinking why to increase the LOAD on AEM when it does not need to process a request.

Regards,

Manas

Avatar

Level 10

Sending data to a 3rd party endpoint is a custom operation. The logic needs to be somewhere. 

In the case of a Form - when you do a submit operation - you need to submit the data where it can be read and then sent to a 3rd party endpoint.

To address this - Java is the best way. AEM is build to handle this type of operations. I would recommend using a Sling Servlet for this use case

Avatar

Correct answer by
Level 5

Hi Manas,

You can do an ajax call to service endpoint from javascript or jquery or any library of your choice. But if you want to do something structural. Then you call the endpoint from Sling Models and map the response from the endpoint some Sling Models and use it via sightly(This might be useful in GET request). For post, put and delete I don't think you need extra AEM layer for external service endpoint its an option. Like if you want to hide your external endpoint url or something then you can use the AEM layer.

~susheel