As an alternative to the solution suggested by @Paddy , using RestSharp version 105.2.3, I found that the following would change the Content-Type request from text/xml to application/xml :
request.AddBody(ji, xmlns); request.Parameters[0].Name = "application/xml"; // default is "text/xml"
Here is what I see for request.Parameters[0] in the Visual Studio debugger after doing the above:
ContentType null Name "application/xml" Type RequestBody Value "<YourSerializedXmlDocHere>...</YourSerializedXmlDocHere>"
As you can see, ContentType is null, which seems to bother me a bit. But, as @Paddy points out, the RestSharp documentation says that " the parameter name will be used as the Content-Type header for the request."
source share