I am trying to upload a file to cloud using jersey client. But here I am getting below response.
InboundJaxrsResponse{context=ClientResponse{method=POST, uri=http://test.net/hello, status=400, reason=400}}
and the source is as below.
final Client client = ClientBuilder.newBuilder().register(MultiPartFeature.class).build();
final JsonObjectBuilder formJson = Json.createObjectBuilder();
formJson.add("name", fileName);
formJson.add("parent", 0);
String jsonStr = formJson.build().toString();
final FileDataBodyPart filePart = new FileDataBodyPart("file", new File(fileLocation));
FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
final FormDataMultiPart multiPart = (FormDataMultiPart) formDataMultiPart
.field(jsonStr, MediaType.MULTIPART_FORM_DATA).bodyPart(filePart);
multiPart.setContentDisposition(FormDataContentDisposition.name("file").fileName(fileLocation).build());
final WebTarget target = client.target("http://test.net/hello");
final Response response = target.request().header("Content-Type", "multipart/form-data")
.header("instanceid", "b05642c8-d231-48fe-a163-d978a6208d98")
.post(Entity.entity(multiPart, "multipart/form-data"));
Can any one help me to out this issue.
Thanks,