REST json payload



This almost seems like a silly question, but I am new to REST services.

I have a rest service that has a method for adding records to my database. 

<Route Url="/userdetails" Method="POST" Call="SaveUserDetails"/>

My REST client sends data using json in the body of the request.  I have verified using debugging tools that the data is actually being sent.

On the server side in my SaveUserDetails method where do I find the json?

What is the proper way to serialize that json into an object?



You can find any sent data as in CSP pages, just because %CSP.REST inherits %CSP.Page. So, you can read it from %request.Content. Very parse JSON, only on versions since 2016. 

s obj = {}.$fromJSON(%request.Content)

You may read more about newest support for JSON in articles here.

I usually write Abstract REST class for handling all REST technical checks and conversions, and inherit all the other REST brokers from it, so they only contain logic related to calling business logic and outputting the results.


Request -> Abstract REST -> REST -> Business Logic -> Data


For example check this abstract broker for json->obj conversion example.