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?
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
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.
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: