Reputation: 2544
I am trying to post some XML data with RestSharp. The web service API that I am posting to expects XML data that has the following structure:
<?xml version="1.0"?>
<rootElement>
<first-child></first-child>
<second-child></second-child>
<rootElement/>
I also have a class that I want to serialize to the required XML and which I will attach to the post request via request.AddObject()
. Here is my class:
public class MyRootElement
{
public string firstchild { get; set; }
public string secondchild { get; set; }
}
Now, here is my problem: How do I get RestSharp to serialize my class so that the dashes are inserted into the names of the XML elements? Currently, the web service API I am posting to is refusing the request because it doesn't recognize the XML I am posting.
Upvotes: 3
Views: 352
Reputation: 78152
Write an ISerializer
implementation that does what you want (probably working with .NET's XmlSerializer), and register it with RestClient.XmlSerializer = new YourSerializer();
Upvotes: 1