I have a Java client which calls one REST web service. The web service accepts data in JSON format and produces data in multipart format. The content-type I have set here for calling the web service is 'application/json'
Now, in the java client I have to get the response and separate multiple files that are there in the multipart response. I have used following code to get the response.
ByteArrayDataSource ds = new ByteArrayDataSource(conn.getInputStream(), "multipart/form-data;boundary=" + boundary);
MimeMultipart multipart = new MimeMultipart(ds);
System.out.println(multipart.getCount());
When final line is executed, I get following exception
javax.mail.MessagingException: Missing start boundary
.
I understand that when it tries to count the files in the response, it does not understand where to start and stop. So, should the webservice set the boundary where files are separated? If yes, how it is done? If no, what can be done?