AMPscript
GetCookieValue
GetFormField
GetPostData
GetQueryStringParameter
GetRequestHeader
GetUserLanguages
Validate Your Server-Side JavaScript using WSProxy
Returns the data from the POST payload sent to the requested resource as a string, converted using the provided optional encoding parameter. A common use case is processing JSON payloads supplied to a page. For accessing data sent via a form POST request, use: Platform.Request.GetFormField(fieldName).
GetPostData(1)
| Ordinal | Type | Description | |
|---|---|---|---|
| 1 | string | Encoding format. If no value is entered, the encoding format will default to Windows-1252. |
1jsonPost = Platform.Request.GetPostData();The example above defaults to Windows-1252 encoding.
If the incoming request uses a different encoding format, such as UTF-8, the encoding can be provided using the optional parameter, shown in the example below.
1jsonPost = Platform.Request.GetPostData('utf-8');The examples below assign the JSON data posted to the page to the “json” variable, converting it to a JS object.
Example using Microsoft Windows-1252 encoding (default):
1<script runat="server" language="JavaScript">
2// load data in as a string
3 var jsonpost = Platform.Request.GetPostData();
4// convert the string to an object
5 var json = Platform.Function.ParseJSON(jsonpost);
6</script>Example using UTF-8 encoding:
1<script runat="server" language="JavaScript">
2 var jsonpost = Platform.Request.GetPostData('utf-8');
3 var json = Platform.Function.ParseJSON(jsonpost);
4</script>