To efficiently construct and add a JSON object or array to your request body, use PRIM_JSON.Writer.

It's essential that you use PRIM_JSON.Writer when your JSON data is big (instead of directly instantiating multiple PRIM_JSON.Object or PRIM_JSON.Array), as PRIM_JSON.Writer is designed to perform better for big data.


     Define_Com Class(#PRIM_SRVM.HttpClientRequest) Name(#Req)

* Create a PRIM_JSON.Writer to efficiently write JSON data

     Define_Com Class(#PRIM_JSON.Writer) Name(#JsonWriter) Textwriter(#StringWriter)
Define_Com Class(#PRIM_IOC.StringWriter) Name(#StringWriter)

* Start constructing the object

     #JsonWriter.BeginObject
#JsonWriter.WriteString Membername('givenName') Value(#EmpGivenName)
#JsonWriter.WriteString Membername('lastName') Value(#EmpLastName)
#JsonWriter.WriteString Membername('address') Value(#EmpAddress)
#JsonWriter.EndObject

#Req.Content.AddString Value(#StringWriter.Text)

* Execute the request


     #Req.DoPost Url('http://yourcompany.com/api/hr/employee')

Next: Creating Multiple Part (Multipart) Body