0

We are tying to create a Salesforce Marketing Cloud webpage endpoint that receives HTTP Post data from an online quiz system, and stores it in a Data Extension.

Can someone provide details on how we can achieve this?

2

If you're comfortable using SSJS, Platform.Request.GetPostData(), conveniently missing from the documentation, will return the whole post body as a string. To parse that data into an object, pass the string to Platform.Function.ParseJSON().

As a caveat, I've run into issues where it returns an empty string on subsequent calls in the same render, so consider memoizing the value somehow if you intend to use it across scopes.

1

If your account supports Cloud Pages, you can create a Cloud Page that uses the RequestParameter function to read each of the POST values from your quiz site, followed by an InsertData function to save the values into a specified Data Extension.

The AMPScript on the Cloud Page could look something like this:

%%[
VAR @DataExtension,@SubscriberKey,@PostValue1,@PostValue2,@PostValue3,@PostValue4
SET @DataExtension = "My Quiz Data Extension"
SET @SubscriberKey = RequestParameter("SubscriberKey")
SET @PostValue1 = RequestParameter("PostValue1")
SET @PostValue2 = RequestParameter("PostValue2")
SET @PostValue3 = RequestParameter("PostValue3")
SET @PostValue4 = RequestParameter("PostValue4")
InsertData(@DataExtension,"SubscriberKey",@SubscriberKey,"PostValue1",@PostValue1,"PostValue2",@PostValue2,"PostValue3",@PostValue3,"PostValue4",@PostValue4)
]%%

You will need to ensure the target Data Extension has the correctly formatted field data types/lengths. Here are some AMPScript formatting functions to cast your data into the correct format:

  • Cameron is correct, however I would recommend making a POST request to the CloudPage as x-www-form-urlencoded and then add name/value pairs for the parameters that you are sending to SFMC in your request payload. For example your POST request would look something like this. – Eliot Harper Mar 9 '17 at 3:19
  • Thanks for responding guys! The webhook is sending us raw JSON data but its in the raw body (Not In Fields). Everything weve been seeing online says that we cant read the raw text out of the body through javascript. How would you go about getting the JSON data from the body into a javascript varible which we can then parse? – Angel Mar 10 '17 at 17:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.