I am trying to Post request with my entities using RestSharp.
But I receive an error:
"System.Xml.XmlException : The '`' character, hexadecimal value 0x60,
cannot be included in a name."
I am placing the list in the body of the query.
var strList = new List<string>();
strList.Add("one");
strList.Add("two");
restRequest.AddBody(strList);
It seems it doesn't like how the generic is serialized. Is there any advices how the list should be passed to request?
You can use Server.HtmlEncode to encode character and decode later.
add: restRequest.RequestFormat = DataFormat.Json before: restRequest.AddBody(strList);
Above version 106.6.x the AddBody() method does not work with Json anymore, even if RequestFormat is set to Json. Also the AddBody() method is marked as depricated and the suggestion is to change it to AddXmlBody() which also does not work (throws the same exception).
The solution is quite simple though: call AddJsonBody() instead and everything works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With