title: Sending gzip data using restclient or postman
body: <p>How can I send gzip data as part of body using restclient or postman?. I used apache restclient 3.2.2 also couldn't able to get the response. I have attached images for reference.</p>
  
  <p>Basically I have an xml file, want to convert it to gzip first and then send as part of body. </p>
  
  <p>To convert to GZip I used online tools to first convert my xml file to gzip and included the converted gzip file as part of body in my restclient.</p>
  
  <p>I got following java code and with code I'm getting response properly. <strong>But not able to get it working in restclient tool!</strong> !
  <img src="https://i.stack.imgur.com/TKs2E.jpg" alt="restclient headers">
  <a href="https://i.stack.imgur.com/qa4gb.jpg" rel="nofollow noreferrer">restclient body</a></p>
  
  <pre><code>    URL url = new URL(String.format("%s?tid=%d",
                  sessionInfo._getMessagesUrl, tpegId));
          connection = (HttpURLConnection) url.openConnection();
          connection.setRequestMethod("POST");
          connection.setRequestProperty("Content-Type",
                  "application/octet-stream");
          connection.setUseCaches(false);
          connection.setDoInput(true);
          connection.setDoOutput(true);
  
          // Convert XML to initial binary payload.
          byte[] bytesToSend = getMessagesRequestXml.getBytes("UTF-8");
          String fileName = "C:\\\\Sanjay\\\\Work\\\\17MM\\\\MM17_body.txt";
          if (this._outputFilename != null) {
              System.out.println(String.format("\nWriting body file '%s'", fileName));
              FileOutputStream s = new FileOutputStream(fileName);
              s.write(bytesToSend);
              s.close();
          }
          dumpBinary("Original GetMessages request", bytesToSend);
  
          // Optionaly compress
          if (this._shouldCompress) {
              byte[] gzippedBytes = compressToGzip(bytesToSend);
              bytesToSend = gzippedBytes;
              dumpBinary("Compressed GetMessages request", bytesToSend);
          }
  
          // Optionally encrypt
          if (sessionInfo._encryptionKey != null) {
              byte[] encryptedBytes = encrypt(bytesToSend, sessionInfo._encryptionKey);
              bytesToSend = encryptedBytes;
              dumpBinary("Encrypted GetMessages request", bytesToSend);
          }
  
          // Send request
          System.out.println(String.format("Sending GetMessages Request: %s\n", url.toString()));         
          DataOutputStream os = new DataOutputStream(
                  connection.getOutputStream());
          os.write(bytesToSend, 0, bytesToSend.length);
          os.flush();
          os.close();
  </code></pre>