title: How to Http Post with Json Body on Flutter
body: <p>I am trying to get data from API. I need to pass value from the body, in postman without a header: application/JSON data is not displayed.</p>
  
  <pre><code>final response = await http.post(
        "http://192.168.10.25:8080/Login/validateusername",
      body: {"username": "user@PYA"},
        headers: {'Content-Type': 'application/json'},
      );
  </code></pre>
  
  <p>Error Message: </p>
  
  <pre><code>E/flutter (28851): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
  E/flutter (28851): Bad state: Cannot set the body fields of a Request with content-type "application/json".
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7NkCr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7NkCr.png" alt="enter image description here"></a></p>