title: How to fix the Validation Error from HTTP Post method
body: <p>I have created a project using default web api template code for asp.net core 5
  <code>&lt;TargetFramework&gt;net5.0&lt;/TargetFramework&gt;</code>
  Then I added a method to test a post request in the WeatherForecastController</p>
  <pre><code>[HttpPost]
   public ActionResult&lt;string&gt; PostMethod([FromBody]string jsonString)
   {            
       return Ok(jsonString);
   }
  </code></pre>
  <p>If I remove the[FromBody] the code works fine. If I add [FromBody] and type something in the body like asdfasdf from swagger, it fails with 400 status error</p>
  <blockquote>
  <p>{
  &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;00-78bd11a5cea5244998ade80c059479d0-8cb569e070ca0047-00&quot;,
  &quot;errors&quot;: {
  &quot;$&quot;: [
  &quot;'a' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.&quot;
  ]
  }
  }</p>
  </blockquote>
  <p>Not able to figure out what the issue is! Could someone explain what causes this and would be great if you can point me to some resource that helps me understand how this validation is done. There was no data annotations done here with this simple code.</p>
  <p>Body in Swagger!! :)
  <a href="https://i.stack.imgur.com/2uqsp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2uqsp.png" alt="enter image description here" /></a></p>
  <p>Thanks in advance
  Murthy</p>