Try doing this.
JSONObject obj = new JSONObject(); obj.put("name", "xyz"); obj.put("age", 25); buildermultipartEntity.addBinaryBody("file", file, ContentType.create("application/octet-stream"), file.getName()); buildermultipartEntity.addTextBody("json", objjsonobject.toString(), ContentType.DEFAULT_BINARY); httpclient = HttpClientBuilder.create() httppost.buildsetEntity(); HttpEntity entity = buildermultipartEntity.build(); postrequest.setEntity(entity);