title: ContentType in header in multipart and in Dio in Flutter
body: <p>I have been trying to upload image and data to server and used both form <code>http-multipart</code> and <code>Dio</code> but server responding <code>502</code> error. As per my research it is happening because i'm providing <code>Content-Type</code> in header. I tried so many ways but  still not working.</p>
  <p>Dio Code</p>
  <pre><code>Map&lt;String, String&gt; headers = new Map&lt;String, String&gt;();
      headers.putIfAbsent(&quot;Authorization&quot;, () =&gt;token);
      headers.putIfAbsent(&quot;Content-Type&quot;, () =&gt; &quot;multipart/form-data&quot;);
  
      try {
        Dio dio = Dio();
        dio.options.contentType = Headers.formUrlEncodedContentType;
        FormData formData = new FormData.fromMap({
          &quot;file&quot;: await MultipartFile.fromFile(_image.path,
              filename: &quot;tshirt_view_kovi.jpg&quot;),
          'name': fields.companyName,
          'type': type,
          'contactId': fields.companyPhone,
          'taxId': fields.taxId,
          'lat': &quot;90&quot;,
          'long': &quot;180&quot;,
          'address': fields.companyAddress,
          'title': fields.representativeTitle,
          'representative': fields.representativeName,
          'state': fields.state,
          'city': fields.city,
          'zip': fields.zip,
        });
        Response response = await dio.post(
            &quot;https://xxxxxxxxx.com/v1/account/business/create&quot;,
            data: formData,
            options: Options(headers: headers));
        Log.e(&quot;Response&quot;,response);
      } catch (e) {
        print(e);
      } 
  </code></pre>
  <p><code>http-multipart</code> code</p>
  <pre><code>Map&lt;String, String&gt; headers = new Map&lt;String, String&gt;();
      headers.putIfAbsent(&quot;Authorization&quot;, () =&gt; token);
      headers.putIfAbsent(&quot;Content-Type&quot;, () =&gt; &quot;multipart/form-data&quot;);
      Map&lt;String, String&gt; body = {
        'name': fields.companyName,
        'type': type,
        'contactId': fields.companyPhone,
        'taxId': fields.taxId,
        'lat': &quot;90&quot;,
        'long': &quot;180&quot;,
        'address': fields.companyAddress,
        'title': fields.representativeTitle,
        'representative': fields.representativeName,
        'state': fields.state,
        'city': fields.city,
        'zip': fields.zip,
      };
  
  
      Log.e(&quot;URL&quot;, url);
      Log.e(&quot;URL&quot;, body);
      Log.e(&quot;TOken&quot;, token);
  
      var uri = Uri.parse(
          &quot;https://xxxxxxxxx.com/v1/account/business/create&quot;);
      var request = new http.MultipartRequest(&quot;POST&quot;, uri);
  
      if (_image != null) {
        //var stream = new http.ByteStream(DelegatingStream.typed(_image.openRead()));
        //var length = await _image.length();
        //var multipartFile = new http.MultipartFile('imageCover', stream, length, filename: _image.path);
        //request.files.add(multipartFile);
  
        request.files.add(
            http.MultipartFile(
                'imageCover',
                File(_image.path).readAsBytes().asStream(),
                File(_image.path).lengthSync(),
                filename: _image.path
                    .split(&quot;/&quot;)
                    .last
            )
        );
      }
  
      if (logoimage != null) {
        // var stream = new http.ByteStream(DelegatingStream.typed(logoimage.openRead()));
        // var length = await logoimage.length();
        // var multipartFile = new http.MultipartFile('imageLogo', stream, length, filename: logoimage.path);
        // request.files.add(multipartFile);
        
        request.files.add(
            http.MultipartFile(
                'imageLogo',
                File(_image.path).readAsBytes().asStream(),
                File(_image.path).lengthSync(),
                filename: _image.path
                    .split(&quot;/&quot;).last
            )
        );
      }
  
      request.fields.addAll(body);
      request.headers['Authorization'] = token;
      request.headers['Content-Type'] = 'multipart/form-data';
      request.send().then((response) {
        print(response.statusCode);
      });
      
  </code></pre>