Question
· Feb 18, 2022

Get value from json post request

i have create rest api service. Trying to get value from post request:

{   "UserName": "Tom",  "UserID": 123 }

here is my class

Class User.REST Extends %CSP.REST
{ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap]
{
<Routes>
<Map Prefix="/restforms" Forward="Form.REST.Main"/> <Route Url="/test" Method="GET" Call="test"/>
<Route Url="/CreatePost" Method="POST" Call="post" Cors="true"/>
</Routes>
}

ClassMethod post() As %Status
{
    set sc = $$$OK
    set req = %request.content
    set userName = req.UserName
    zw userName
    return $$$OK
}

 

getting error:

{
    "errors": [
        {
            "code": 5002,
            "domain": "%ObjectErrors",
            "error": "?????? #5002: ??????: <PROPERTY DOES NOT EXIST>zpost+2^User.REST.1 *content,%CSP.Request",
            "id": "CacheError",
            "params": [
                "<PROPERTY DOES NOT EXIST>zpost+2^User.REST.1 *content,%CSP.Request"
            ]
        }
    ],
    "summary": "?????? #5002: ??????: <PROPERTY DOES NOT EXIST>zpost+2^User.REST.1 *content,%CSP.Request"
}

$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.2 (Build 867_4_20165U) Mon Aug 17 2020 11:28:28 EDT
Discussion (3)1
Log in or sign up to continue