Am currently trying to use the Web API and accept a HTTP POST containing an XML. I was under the impression that this could be automatically deserialized into an object, but I am missing something.
public class Item
{
public int Value { get; set; }
}
This one works, I receive the XML from SoapUI and can act upon it
[HttpPost]
public HttpResponseMessage Post(int id, HttpRequestMessage request)
{
var doc = new XmlDocument();
doc.Load(request.Content.ReadAsStreamAsync().Result);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, new Item() { Value = id });
return response;
}
I'd like to have this though:
[HttpPost]
public HttpResponseMessage Post(int id, [FromBody]List<Item> items)
{
return Request.CreateResponse(HttpStatusCode.OK);
}
Trying to post this:
<Items><Item><Value>1</Value></Item></Items>
What did I miss?