title: How to resolve "An error occurred while deserializing input data." when sending XML to an asp net core web api?
body: <p>Controller</p>
  <pre><code>[ApiController]
  [Route(&quot;[controller]&quot;)]
  public class AodsController
  {
      [HttpPost]
      [Consumes(&quot;application/xml&quot;)]
      public async Task Post([FromBody]TestDto model, CancellationToken cancellationToken)
      {
  
      }
  
      [HttpGet]
      public async Task&lt;string&gt; Get(CancellationToken cancellationToken)
      {
          return &quot;you did it&quot;;
      }
  }
  </code></pre>
  <p>TestDto</p>
  <pre><code>public sealed class TestDto
  {
      public string[] TestValue { get; set; }
  }
  </code></pre>
  <p>I'm posting this in the body</p>
  <pre><code>&lt;TestDTO xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;
          &lt;TestValue&gt;
                  &lt;string&gt;T1&lt;/string&gt;
                  &lt;string&gt;T&lt;/string&gt;
          &lt;/TestValue&gt;
  &lt;/TestDTO&gt;
  </code></pre>
  <p>And in <code>Startup.cs</code> I have this line</p>
  <pre><code>services
      .AddControllersWithViews()
      .AddXmlSerializerFormatters()
      .AddXmlDataContractSerializerFormatters();
  </code></pre>
  <p>Postman gives me this errror</p>
  <pre><code>{
      &quot;type&quot;: &quot;https://tools.ietf.org/html/rfc7231#section-6.5.1&quot;,
      &quot;title&quot;: &quot;One or more validation errors occurred.&quot;,
      &quot;status&quot;: 400,
      &quot;traceId&quot;: &quot;|14250dd4-4d75412529990287.&quot;,
      &quot;errors&quot;: {
          &quot;&quot;: [
              &quot;An error occurred while deserializing input data.&quot;
          ]
      }
  }
  </code></pre>
  <p>What am I missing?</p>