title: Flutter: Http post request Error Invalid media type: expected
body: <p>I am making an http post request using http dependency. I am facing the below error in my response. I am posting my code below:</p>
  
  <pre><code>flutter: Error on line 1, column 32: Invalid media type: expected /[^()&lt;&gt;@,;:"\\\/[\]?={} \t\x00-\x1F\x7F]+/.
        ╷
      1 │ application/json;charset=utf-8;
        │
  
                              ^
  </code></pre>
  
  <p>below is the code in which i am facing the error:</p>
  
  <pre><code>try {
      String url = 'https://app.restroapp.com/';
      Map&lt;String, String&gt; headers = {"Content-type": "application/json"};
      String json = '{"device_id": "abaf785580c22722", "user_id": "", "device_token": "","platform":"android"}';
  
      // make POST request
      Response response = await post(Uri.encodeFull(url), headers: headers, body: json);
      // check the status code for the result
      int statusCode = response.statusCode;
      // this API passes back the id of the new item added to the body
      String body = response.body;
  
      print(statusCode);
      print(body);
  
    } catch (e) {
      print(e);
    }
  </code></pre>
  
  <p>it is wroking in postman, please see the below image:
  <a href="https://i.stack.imgur.com/PBgWU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PBgWU.png" alt="enter image description here"></a></p>