title: Uploading files to REST from java side works, from python not
body: <p>We are testing Saperion REST web service and everything goes okay except file upload. Everything goes ok from java side:</p>
  
  <pre><code>public HttpResponse insertDocument(String docId) throws IOException {
  
      RestClient client = new RestClient();
  
      byte[][] file1 = null;
      System.out.println("insertDocument: Reading attachment files to insert...");
      try {
  
          file1 = new byte[][]
                  {
  
                   client.readFile("/usr/local/www/test.pdf")
  
                  };
  
      } catch (Exception ex) {
          System.out.println("******** insertDocument catch ******");
          System.out.println("insertDocument: File not read...");
          System.out.println("insertDocument: Error: " + ex.getMessage());
      }
  
      HttpClient httpclient = new DefaultHttpClient();
  
      try {
          String url = SERVER + INSERT_DOCUMENT_OPERATION;
          System.out.println("insertDocument: url - " + url + "/" + docId);
  
          HttpPost httpPost = new HttpPost(url);
          httpPost.setHeader("Accept", "text/plain");
          httpPost.setHeaders(getAuthentication());
  
  
          // META
          String str = "&lt;query id=\"001\"&gt;" +
                  "&lt;docid&gt;" + docId + "&lt;/docid&gt;" +
                  "&lt;dochead&gt;" +
                  "&lt;/dochead&gt;" +
                  "&lt;attachments count=\"" + file1.length + "\"&gt;";
  
  
          for (int i = 0; i &lt; file1.length; i++) {
              str += "&lt;entry&gt;&lt;filename&gt;" + docId + "_" + i + ".pdf" + "&lt;/filename&gt;" +
                      "&lt;filedata/&gt;" +
                      "&lt;/entry&gt;";
          }
  
          str += "&lt;/attachments&gt;" +
                  "&lt;/query&gt;";
  
          System.out.println("insertDocument: str - " + str);
  
          MultipartEntity entity = new MultipartEntity();
          entity.addPart("xmlString", new StringBody(str));
  
          for (byte[] file : file1)
              entity.addPart("file", new ByteArrayBody(file, "file"));
  
          httpPost.setEntity(entity);
  
  
          HttpResponse response = httpclient.execute(httpPost);
  
          System.out.println("insertDocument: return response ...");
          return response;
  
      } finally {
          httpclient.getConnectionManager().shutdown();
      }
  }
  </code></pre>
  
  <p>This, is how looks request content:</p>
  
  <pre><code>POST /saperion/services/rest/insertDocument HTTP/1.1
  RC_USER: user
  RC_USER_PASSWORD: pass
  Content-Length: 8476
  Content-Type: multipart/form-data; boundary=3mzL6oR0- E0dudMZ_pV3OVTE41pV4yH
  Host: appdevel4.kada.lan
  Connection: Keep-Alive
  User-Agent: Apache-HttpClient/4.2.2 (java 1.5)
  --3mzL6oR0-E0dudMZ_pV3OVTE41pV4yH
  
  Content-Disposition": "form-data; name="xmlString"
  Content-Type: text/plain; charset=US-ASCII"
  Content-Transfer-Encoding: 8bit
  &lt;query id="001"&gt;&lt;docid&gt;55&lt;/docid&gt;&lt;dochead&gt;&lt;/dochead&gt;&lt;attachments     count="1"&gt;&lt;entry&gt;&lt;filename&gt;55_0.pdf&lt;/filename&gt;&lt;filedata/&gt;&lt;/entry&gt;&lt;/attachments&gt;&lt;/query&gt;
  --3mzL6oR0-E0dudMZ_pV3OVTE41pV4yH
  Content-Disposition:form-data; name="file"; filename="file"
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: "binary"
  binary pdf content
  --3mzL6oR0-E0dudMZ_pV3OVTE41pV4yH
  </code></pre>
  
  <p>Here code from python side:</p>
  
  <pre><code>xml="""&lt;query id="001"&gt;
          &lt;docid&gt;56&lt;/docid&gt;
          &lt;dochead&gt;&lt;/dochead&gt;
          &lt;attachments count="1"&gt;
              &lt;entry&gt;
                  &lt;filename&gt;56_0.pdf&lt;/filename&gt;
                  &lt;filedata/&gt;
              &lt;/entry&gt;
          &lt;/attachments&gt;
          &lt;/query&gt;"""
  
  
  url="http://appdevel4.kada.lan/saperion/services/rest/insertDocument/56"
  files = {'xmlString': (None, xml, "text/plain; charset=US-ASCII", {'Content-Transfer-Encoding':'8bit'} ), 'file': ('file', open('/usr/local/www/test.pdf', 'rb'), "application/octet-stream", {'Content-Transfer-Encoding':'binary'})}
      headers={
      'Host':'appdevel4.kada.lan',
      'POST': '/saperion/services/rest/insertDocument HTTP/1.1',
      'Connection': 'Keep-Alive',
      'RC_USER':'user', 
      'RC_USER_PASSWORD':'passwd'
      }
      response = requests.post("http://appdevel4.kada.lan/saperion/services/rest/insertDocument/55", files=files, headers=headers)
  </code></pre>
  
  <p>Here are content of python request:</p>
  
  <pre><code>POST http://appdevel4.kada.lan/saperion/services/rest/insertDocument/56
  Content-Length: 8521
  Connection: Keep-Alive
  Host: appdevel4.kada.lan
  Cookie: JSESSIONID=li0vmwnqKmtcWF2sWk06cFWG
  RC_USER: user
  RC_USER_PASSWORD: passwd
  POST: /saperion/services/rest/insertDocument HTTP/1.1
  Content-Type: multipart/form-data; boundary=477579b8a0b04c9286c7c78ce3bb72b5
  
  --477579b8a0b04c9286c7c78ce3bb72b5
  Content-Disposition: form-data; name="xmlString"
  Content-Type: text/plain; charset=US-ASCII
  Content-Transfer-Encoding: 8bit
  
  &lt;query id="001"&gt;
  &lt;docid&gt;56&lt;/docid&gt;
  &lt;dochead&gt;&lt;/dochead&gt;
  &lt;attachments count="1"&gt;
  &lt;entry&gt;
  &lt;filename&gt;56_0.pdf&lt;/filename&gt;
  &lt;filedata/&gt;
  &lt;/entry&gt;
  &lt;/attachments&gt;
  &lt;/query&gt;
  
  --477579b8a0b04c9286c7c78ce3bb72b5
  Content-Disposition: form-data; name="file"; filename="file"
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: binary
  PDF content
  --477579b8a0b04c9286c7c78ce3bb72b5--
  </code></pre>
  
  <p>So, contents of java and python requests, practically are the same, but java uploads are successful, but python produces 404 Not found. </p>