title: flutter: Content-type must be application/json
body: <p>I'm having issues with an http post request. I get the response 'Content-type must be application/json', however I am setting the header to specify the content is of type json.</p>
  
  <pre><code>const Map&lt;String, String&gt; header = {
    'Content-type': 'application/json',
    'Accept': 'application/json',
  };
  
  static void init() async {
      var body =
        {
          "username": username, // String username defined above
          "password": password, // String password defined above
        };
  
      var response = await http.post(url, body: json.encode(body), headers: header);
      print(response.body);
  }
  </code></pre>
  
  <p>As mentioned above, I'm expecting this to work and return a valid json response, however I am receiving an error code of 400, with the message 'Content-type must be application/json'. I'm not quite sure how to fix this, I have used this method to deliver http.Post requests various other times and it has always worked.</p>