SBM ModScript Reference → Programming SBM ModScript → Shell Properties → Shell Property Descriptions → PostData Shell Properties
The PostData Shell property is available if the script is accessed via "ScriptPage" (URL Direct Access Context), and if the Content Type passed to the URL is "application/json", and if the HTTP call is a POST. The included POST data will be available via PostData.
string (output). The POST data from the HTTP call.
You can use an HTTP POST to send JSON data to your script in the URL Direct Access Context. The POST body of the HTTP message is added as a string-Variant to the shell object with Shell.PostData() to provide the body.
First, note the following requirements:
SBM ModScript has from_json(), which will convert the string from JSON to int and string values, with JSON object becoming a Map and JSON array becoming a Vector. As there is no implicit conversion from Variant to string, and since the values on the Shell are Variant, the Variant must be explicitly converted to string while being passed to from_json().
var y = from_json( Shell.PostData().to_string() );
An example of using the parsed values after calling from_json() is available in Sample Five: RESTDataSource.
Copyright © 2007–2019 Micro Focus or one of its affiliates. All rights reserved.