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 Answers 2

4

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:

2
  • 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. Mar 9, 2017 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, 2017 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .