AddObject
Sets the request body to an object serialized as JSON.
| myRestRequest.AddObject(obj: ( string | object )):RestRequest
|
Parameters
( string | object ) obj
The object to send, or a JSON string.
Returns
The current RestRequest instance.
The object is serialized to JSON and the request method is set to POST.
Examples
Send a JSON body built from form data
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | var lines = $Xml.SelectAll('Lines/Line', function (line) {
return {
product : line.Evaluate('Product'),
quantity : line.EvaluateNumber('Quantity')
};
});
var result = $Rest.Create('https://api.example.com/')
.Request('orders')
.AddObject({
customerId : $Xml.Evaluate('Customer/Id'),
lines : lines
})
.ExecuteJson();
|
See Also