title: How to set header for multipart httppost?
body: <p>I am trying  this code to upload image and text on server but with this code i got some error "<strong>content-length header already present</strong>" or if i dont set content lenget then it return "<strong>411 length required</strong>"</p>
  
  <p>Please give me some solutions </p>
  
  <p>this is my code</p>
  
  <pre><code>    String url = webserviceURLs.createQuestion+"?token"+OkayUserProfileProps.tocken; 
      try { 
          HttpClient httpclient = new DefaultHttpClient(); 
          HttpPost httppost = new HttpPost(url); 
          httppost.setHeader("Content-Type", "multipart/form-data");
          httppost.addHeader("Accept", "application/json");
          byte[] abc = convertImageToByte(Uri.parse(imageName.get(0)));
  
          InputStream in = new ByteArrayInputStream(abc);
          ContentBody mimePart = new InputStreamBody(in, "file1"); 
          MultipartEntity reqEntity = new MultipartEntity();
  
          reqEntity.addPart("userquestion[question_id]", new StringBody("2")); 
          reqEntity.addPart("userquestion[looks][0][photo]", mimePart);
          httppost.setEntity(reqEntity);   
  
          int a=abc.length;
          httppost.setHeader(HTTP.CONTENT_LEN,""+abc.length);
  
          HttpResponse response = httpclient.execute(httppost); 
          HttpEntity resEntity = response.getEntity(); 
  
  
          if (resEntity != null) {       
              String retSrc = EntityUtils.toString(resEntity);
              System.out.println("Responce "+retSrc);
  
          }
  
  
  
          return null;
      } catch (Exception e) { 
          // TODO Auto-generated catch block
          Log.e("Exception", e.getMessage() + ""); 
          return null;
      } 
  </code></pre>