title: unable to send post request in dio - flutter
body: <p>I'm trying to send Post request from Flutter(dio) to my Flask Restful API and I want to give the request body in form-data because an image file needs to be sent. The Flask app with the help of Postman - it works fine with my Postman's form-data, but when I tried with Flutter's dio package to Post the form-data to Flask gets an error in Flask.</p>
  <p>The dio code is :</p>
  <pre class="lang-dart prettyprint-override"><code>Future&lt;List&gt; apiRequest(int N ,File file) async {
    String url = &quot;http://10.0.2.2:5000/&quot;;
    // HttpClient httpClient = new HttpClient();
    Post _post = Post();
        
    var bytes = await file.readAsBytes();
    //TODO : dio post request
    var dio = new Dio();
    MultipartFile  multipartFile = new MultipartFile.fromBytes(bytes);
    FormData formData = new FormData();
    dio.options.headers = {&quot;content-type&quot; :&quot;multipart/form-dataitem&quot;};
    formData.fields.add(MapEntry(&quot;index&quot; , N.toString()));
    formData.files.add(MapEntry(&quot;file&quot;,multipartFile));
    print(formData);
    await dio.post(url, data: formData,options: Options(
        method: 'POST',
        responseType: ResponseType.json // or ResponseType.JSON
    )).then((response){
      //response stuffs
    });
  
  </code></pre>
  <p>Postman request which works fine</p>
  <p><img src="https://i.stack.imgur.com/V7eeQ.png" alt="this image consists of my postman's Post request which works fine" /></p>
  <p>Flask statements that uses this form-data</p>
  <pre><code>fromJson = request.form['index']
  Img = request.files['file']
  </code></pre>
  <p>The error in the Flask console</p>
  <pre><code>{exception: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.}
  </code></pre>