Using .NET Framework 4.7, C#, Postman.
I make a request with request header Content-Type set to "application/xml". Body looks something like this:
<?xml version="1.0" encoding="utf-8"?>
<BookOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<books>
<Book>
<bookName>Buzz</bookName>
<code>1234</code>
</Book>
</books>
</BookOrder>
I thought, out of the box, .NET Framework 4.7 accepts XML requests and will respond in the same way or am I mistaken please?
Instead, I have to set in Global.asax:
var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
xml.UseXmlSerializer = true;
Why is this? I have tried without setting it, but it won't accept my XML no matter how I format it. Any ideas please?
Thanks
My classes are:
public class BookOrder
{
public List<Book> books{ get; set; }
}
public class Book
{
public string bookName { get; set; }
public string code { get; set; }
}