I have an API method that has a FromBody Model and it's working properly with JSON data as input but when I use XML as an input parameter, it throws an error. I tried using XMLserialiser in the startup file.
services.AddControllers(options =>
{
options.RespectBrowserAcceptHeader = true;
options.InputFormatters.Add(new XmlSerializerInputFormatter(options));
options.OutputFormatters.Add(new XmlSerializerOutputFormatter());
})
Nothing worked.
[HttpPost]
public IActionResult Post([FromBody]Model model)
{
return Ok();
}
Any help would be appreciated.