How to add text to request body in RestSharp
To Add to @dmitreyg's answer and per @jrahhali's comment to his answer, in the current version, as of the time this is posted it is v105.2.3
, the syntax is as follows:
request.Parameters.Add(new Parameter() {
ContentType = "application/json",
Name = "JSONPAYLOAD", // not required
Type = ParameterType.RequestBody,
Value = jsonBody
});
request.Parameters.Add(new Parameter() {
ContentType = "text/xml",
Name = "XMLPAYLOAD", // not required
Type = ParameterType.RequestBody,
Value = xmlBody
});
Here is how to add plain xml string to the request body:
req.AddParameter("text/xml", body, ParameterType.RequestBody)
;