@@ -82,7 +82,7 @@ ClassMethod GetPerson(id As %Integer) As %Status
82
82
83
83
Set person = ##class (Sample.Person ).%OpenId (id )
84
84
85
- If '$IsObject (person ) Quit ..Http404 ()
85
+ If '$IsObject (person ) Quit ..ReportHttpStatusCode ()
86
86
87
87
Do person .%JSONExport ()
88
88
@@ -92,21 +92,22 @@ ClassMethod GetPerson(id As %Integer) As %Status
92
92
/// Creates a new Sample.Person record
93
93
ClassMethod CreatePerson () As %Status
94
94
{
95
- #dim tSC As %Status = $$$OK
95
+ #dim tSC As %Status = $$$OK
96
96
#dim e As %Exception.AbstractException
97
+
97
98
Set person = ##class (Sample.Person ).%New ()
98
- Set data = {}.%FromJSON (%request .Content )
99
+ Set requestContent = %request .Content
100
+ Set requestContentStr = requestContent .%ToJSON ()
101
+ Set data = {}.%FromJSON (requestContentStr )
99
102
100
-
101
- $$$TOE(tSC ,person .%JSONImport (data ))
102
- $$$TOE(tSC ,person .%Save ())
103
+ $$$TOE(tSC , person .%JSONImport (data ))
104
+ $$$TOE(tSC , person .%Save ())
103
105
104
106
Set %response .Status = 204
105
107
Set %response .ContentType = ..#CONTENTTYPEJSON
106
- //d data.%ToJSON()
107
108
Do person .%JSONExport ()
108
109
109
- Quit tSC
110
+ QUIT tSC
110
111
}
111
112
112
113
/// Update a record in Sample.Person with id
@@ -115,9 +116,11 @@ ClassMethod UpdatePerson(id As %Integer) As %Status
115
116
#dim tSC As %Status = $$$OK
116
117
#dim e As %Exception.AbstractException
117
118
Set person = ##class (Sample.Person ).%OpenId (id )
118
- If '$IsObject (person ) Return ..Http404 ()
119
- Set data = {}.%FromJSON (%request .Content )
119
+ If '$IsObject (person ) Return ..ReportHttpStatusCode ()
120
120
121
+ Set requestContent = %request .Content
122
+ Set requestContentStr = requestContent .%ToJSON ()
123
+ Set data = {}.%FromJSON (requestContentStr )
121
124
122
125
$$$TOE(tSC ,person .%JSONImport (data ))
123
126
$$$TOE(tSC ,person .%Save ())
@@ -141,7 +144,6 @@ ClassMethod DeletePerson(id As %Integer) As %Status
141
144
$$$TOE(tSC ,person .%DeleteId (id ))
142
145
143
146
Set %response .Status = 200
144
-
145
147
Set %response .ContentType = ..#CONTENTTYPEJSON
146
148
147
149
Quit tSC
0 commit comments