Page History
To efficiently construct and add a JSON object or array to your request body, use
...
PRIM_
...
JSON.Writer.
It's essential that you use XPRIMPRIM_JsonWriter JSON.Writer when your JSON data is big (instead of directly instantiating multiple XPRIMPRIM_JsonObject JSON.Object or XPRIMPRIM_JsonArrayJSON.Array), as XPRIMPRIM_JsonWriter JSON.Writer is designed to perform better for big data.
Define_Com Class(#XPRIM#PRIM_HttpRequestSRVM.HttpClientRequest) Name(#Req)
* Create an XPRIM_JsonWriter a PRIM_JSON.Writer to efficiently write JSON data
Define_Com Class(#XPRIM#PRIM_JsonWriterJSON.Writer) Name(#JsonWriter)
* Set the writer to output the JSON to the HTTP request object
Textwriter(#StringWriter)
#JsonWriter.SetOutputToHttpRequest HttpRequest(#ReqDefine_Com Class(#PRIM_IOC.StringWriter) Name(#StringWriter)
* Start constructing the object
#JsonWriter.BeginObject
#JsonWriter.WriteString NameMembername('givenName') Value(#EmpGivenName)
#JsonWriter.WriteString NameMembername('lastName') Value(#EmpLastName)
#JsonWriter.WriteString NameMembername('address') Value(#EmpAddress)
#JsonWriter.EndObject
#Req.Content.AddString Value(#StringWriter.Text)
* Execute the request
#Req.DoPost Url('http://yourcompany.com/api/hr/employee')