I want to create an employee information in the system by uploading an image along with employee data. I am able to do it with different rest calls using jersey. But I want
I want add a comment on peeskillet but don't have 50 reputation points, hence adding as an answer:
When I tried @peeskillet solution with Jersey client 2.21.1, there was 400 error. It worked when I added following in my client code:
MediaType contentType = MediaType.MULTIPART_FORM_DATA_TYPE;
contentType = Boundary.addBoundary(contentType);
Response response = t.request().post(
Entity.entity(multipartEntity, contentType));
instead of hardcoded MediaType.MULTIPART_FORM_DATA in post request call.