Good Day Fellow Coders,
I'm working on a simple Web API (.NET CORE 2.0) that accepts XML request.
Controller:
Route("api/Product")]
public class ProductController : Controller
{
[Route("List")]
[HttpPost]
public IActionResult List([FromBody]Body request)
{
return Ok();
}
}
Class:
public class ProductRequest
{
public string ProductId { get; set; }
public string ProductDescription { get; set; }
}
[XmlRoot(ElementName = "Katawan")]
public class Body
{
[XmlElement(ElementName = "Product", Namespace = "")]
public ProductRequest ProductRequest { get; set; }
}
This works fine and able to see the the actual request when debugging, however we did some changes on the request. We added some namespace on the Body. See below Image
After we added the prefix 'x', the request is now always null. I would like to request for your help here. I've already did some research like adding a DataContract and DataMember Attribute and set the namespace to blank, still no luck.
Update
We added a namespace for x
but still the same, we also added new prefix on the Product. This is now the final xml.
<?xml version="1.0"?>
<x:Katawan
xmlns:x="http://www.w3.org/1999/xhtml">
<v:Product>
<ProductId>string</ProductId>
<ProductDescription>string</ProductDescription>
</v:Product>
</x:Katawan>