Embed with Json CustomRequestBody Example

In this example, a page that handles a Json request and returns a Json result is embedded.

This demo application page to be embedded has the following SXML logic:

Smartsite SXML CopyCode image Copy Code
<se:json />
{buffer.set(t, 
 scope.json.getvalue('data.title', 
 default='-')
 )}
<se:json localid="response">{}</se:json>
{scope.response.set("result", string.toupper($t), string)}
{page.setforcedresult(scope.response.get(), "application/json")}

Smartsite SXML CopyCode image Copy Code
<se:embed location="JSONDEMOPAGE01" save="responseJson">
    <se:parameters>
        <se:parameter name="customrequestbody">
            {data: {
                title: "Hello world"
            }}
        </se:parameter>
        <se:parameter name="customrequestcontenttype">application/json</se:parameter>        
    </se:parameters>
</se:embed>

<se:json localid="response">{buffer.get(responseJson)}</se:json>
{scope.response.getvalue(result)}
Example Result CopyCode image Copy Code
HELLO WORLD