Skip to content

Instantly share code, notes, and snippets.

@danieldrasdo
Forked from jdeblank/ssjs_GetPostData.js
Last active February 18, 2020 21:35
Show Gist options
  • Save danieldrasdo/c6f4d6a10cb23b6870be3a3ad4d225bb to your computer and use it in GitHub Desktop.
Save danieldrasdo/c6f4d6a10cb23b6870be3a3ad4d225bb to your computer and use it in GitHub Desktop.
/*
Great Adam Spriggs suggestion...
https://salesforce.stackexchange.com/questions/145037/developing-and-testing-cloudpages
...is to use TreatAsContent() to bypass the CloudPage caching
%%=TreatAsContent(HttpGet(Concat("https://www.domain.com/your/webhook.html?x=",GUID())))=%%
*/
<script runat="server">
Platform.Load("core","1.1.1");
/*
Example that handles JSON data POSTed to this page.
e.g '{"firstname":"Joe","lastname":"Bloggs"}'
*/
var jsonPost, jsonData;
//Use JSON in post content
jsonPost = Platform.Request.GetPostData();
if (jsonPost.substring(0, 1) != '-') {
// Parse JSON
jsonData = Platform.Function.ParseJSON(jsonPost);
var FirstName = jsonData.firstname;
var LastName = jsonData.lastname;
Write("Hello " + FirstName + " " + LastName);
// Hello Joe Bloggs
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment