• We are working on a requirement where we need to send customer details (FirstName , LastName , EmailAddress) entered into web-form to "External API end point"
  • So once customer submit his/her details via web-form , customer will redirect to "Thank You Page" (Cloudpage)

Implementation we did as below

  • Once customer submits details via web-form we are sending these details to "Thank you page" via Form -POST method , also on Thank you page we are using HTTPPOST2 ampscript function to send these details to "External-API-Endpoint" as below.

Code on "Thank you Page"


set @FirstName = RequestParameter('FirstName')
set @LastName = RequestParameter('LastName')
set @email = RequestParameter('email')

set @authurl = "https://staging/SampleEndpoint/"
set @@payload = Concat('{"FirstName": "',@FirstName,'","LastName": "',@LastName,'","Email": "',@email,'"}')
set @key = "xxxxxxxxx-secret-key"

SET @httppost = HTTPPost2(@authurl,"application/json",@payload,false,@apistatusCode,@respheader,"Key",@key)


Issue -:

  • HTTPPOST2 ampscript is taking too much time , resulting slow load of Thank you Page. ( Approx 10-15 seconds )
  • Thank you Page is loading only after HTTPPOST2 ampscript processing
  • We see Success (200) , and successfully send details to "External API endpoint" but take too much time to load Thank you page

Additional Query I have

Is HTTPPOST2 ampscript function is a secured method/way to send Customer details to external API endpoint from CloudPage?

  • 1
    If your external API end-point can receive the posted informations with a delay, then you could use Automation Studio and a Script activity to make the actual call (informations taken from the Cloud Page DE). That way, your Thank you page would display quickly, and regarding your second question, this is perfectly safe. Aug 3 at 21:09
  • It honestly sounds like your endpoint is the issue. The throughput and processing of your endpoint is usually the major determinant on the length of time it takes an HTTP call to complete. There are client-side options, but that is not likely a good idea as it exposes the information. I would both have a look at that external endpoint to optimize it and shift from real time loading to the API and instead use Auto Studio as @FrançoisPerret mentioned in his comment. Aug 4 at 15:52
  • Hi Gortonington , François Thank you for replies , I tested this "API-end point" and "Payload" using Postman tool and I received instance response (200 - Ok) from the server . I am thinking if we can use JSON code resource , post data from Thank you Page using HTTPPOst and process final API-endpoint on JSON code resource , so there will be 3 Components i.e. 1. Web-form (main-cloudpage) , 2.Thank you Page (Landing-Page with HTTPPOST ampscript to post payload to Json code resource) 3. JSON (Code resource to process final HTTPPOST2 call to external api-endpoint, Please share your thoughts.
    – JNC
    Aug 4 at 17:25
  • External API endpoint is of "Azure" it is working fine using postman with instant success and response
    – JNC
    Aug 4 at 17:29
  • 1
    I would not discount the endpoint as a potential part of the issue. POSTman is not a 1:1 match with POSTing from SFMC (Context, certificates, etc) so there could be some mismatch causing delays still. Second I would not recommend your addition of code resource page as I believe that is going to come to same issue of the Thank you page will not load until the POST to the 3rd page finishes essentially adding time instead of reducing time. Aug 5 at 12:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.