Skip to main content
deleted 86 characters in body
Source Link

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); 

Try doing this.

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

Try doing this.

multipartEntity.addBinaryBody("file", file, ContentType.create("application/octet-stream"), file.getName()); multipartEntity.addTextBody("json", jsonobject.toString(), ContentType.DEFAULT_BINARY);  httppost.setEntity(multipartEntity.build()); 
added 36 characters in body
Source Link

Try doing this.

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

Try doing this.

JSONObject obj = new JSONObject(); obj.put("name", "xyz"); obj.put("age", 25); builder.addBinaryBody("file", file, ContentType.create("application/octet-stream"), file.getName()); builder.addTextBody("json", obj.toString(), ContentType.DEFAULT_BINARY); httpclient = HttpClientBuilder.create().build(); HttpEntity entity = builder.build(); 

Try doing this.

JSONObject obj = new JSONObject(); obj.put("name", "xyz"); obj.put("age", 25); builder.addBinaryBody("file", file, ContentType.create("application/octet-stream"), file.getName()); builder.addTextBody("json", obj.toString(), ContentType.DEFAULT_BINARY); httpclient = HttpClientBuilder.create().build(); HttpEntity entity = builder.build(); postrequest.setEntity(entity); 
Source Link

Try doing this.

JSONObject obj = new JSONObject(); obj.put("name", "xyz"); obj.put("age", 25); builder.addBinaryBody("file", file, ContentType.create("application/octet-stream"), file.getName()); builder.addTextBody("json", obj.toString(), ContentType.DEFAULT_BINARY); httpclient = HttpClientBuilder.create().build(); HttpEntity entity = builder.build();