I have read through the various questions already posed here regarding this subject and i'm still no closer to solving my problem.
I am trying to Deserialize this xml response:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<SubmissionResult>
<Result>ACCEPTED</Result>
<SubmissionID>
<RefNo>77587-1425386500</RefNo>
<Submitted>9</Submitted>
<ValidNo>7</ValidNo>
<InvalidNo>2</InvalidNo>
<InvalidNo_1>08452782055</InvalidNo_1>
<InvalidNo_2>01234567890</InvalidNo_1>
<TextvID>77587-1425386500</TextvID>
</SubmissionID>
<Credits>999999</Credits>
</SubmissionResult>
Using these classes:
[XmlRoot ("SubmissionResult")]
public class SubmissionResult
{
[XmlElement ("Result")]
public string Result { get; set; }
public SubmissionID SubmissionID { get; set; }
[XmlElement("Credits")]
public int Credits { get; set; }
}
public class SubmissionID
{
[XmlElement("RefNo")]
public int RefNo { get; set; }
[XmlElement("Submitted")]
public int Submitted { get; set; }
[XmlElement("ValidNo")]
public int ValidNo { get; set; }
[XmlElement("TextVID")]
public string TextVID { get; set; }
}
However I am only ever returning null and 0 values, which I assume are the default.
Here is the code to get the results and hopefully deserialize:
try
{
var request = new RestRequest();
request.RequestFormat = DataFormat.Xml;
request.Resource = APIURL;
request.RootElement = "SubmissionResult";
SubmissionResult r = Execute<SubmissionResult>(request);
}
public static T Execute<T>(RestRequest request) where T : new()
{
var client = new RestClient();
client.BaseUrl = new Uri("https://www.textvertising.co.uk/_admin/api", UriKind.Absolute);
var response = client.Execute<T>(request);
return response.Data;
}
Many thanks in advance for any help you can provide.
CS