public static @Nullable RequestBody createGzip(final MediaType mediaType,final String body){
  ByteArrayOutputStream gzipByteArrayOutputStream=new ByteArrayOutputStream();
  try {
    OutputStream gzipOutputStream=new GZIPOutputStream(gzipByteArrayOutputStream);
    gzipOutputStream.write(body.getBytes());
    gzipOutputStream.close();
  }
 catch (  IOException e) {
    return null;
  }
  return RequestBody.create(mediaType,gzipByteArrayOutputStream.toByteArray());
}

public static @ Nullable RequestBody createGzip ( final MediaType mediaType , final String body ) { ByteArrayOutputStream gzipByteArrayOutputStream = new ByteArrayOutputStream ( ) ; try { OutputStream gzipOutputStream = new GZIPOutputStream ( gzipByteArrayOutputStream ) ; gzipOutputStream . write ( body . getBytes ( ) ) ; gzipOutputStream . close ( ) ; } catch ( IOException e ) { return null ; } return RequestBody . create ( mediaType , gzipByteArrayOutputStream . toByteArray ( ) ) ; }
creates a requestbody from a mediatype and gzip - ed body string
