try {
logger.debug("Constructing multipart");
MimeMultipart mp = new MimeMultipart("mixed");
logger.debug("Storing JSON response as first section");
InternetHeaders rootHdr = new InternetHeaders();
rootHdr.addHeader("Content-Type", "application/json");
rootHdr.addHeader("Content-Disposition", "form-data; name=\"root-fields\"");
byte[] rootData = jsonResponse.getBytes();
mp.addBodyPart(new MimeBodyPart(rootHdr, rootData));
logger.debug("Send second section as text attachment");
InternetHeaders textPartHeader = new InternetHeaders();
textPartHeader.addHeader("Content-Type", "text/plain");
textPartHeader.addHeader("Content-Disposition", "form-data; name=\"textpart.txt\"");
byte[] textPartData = "Hello from OneAPI".getBytes();
mp.addBodyPart(new MimeBodyPart(textPartHeader, textPartData));
logger.debug("Send third section as html attachment");
InternetHeaders htmlPartHeader = new InternetHeaders();
htmlPartHeader.addHeader("Content-Type", "text/html");
htmlPartHeader.addHeader("Content-Disposition", "form-data; name=\"htmlpart.htm\"");
byte[] htmlPartData = "<html><body><p><strong>Hello from OneAPI</strong></p></body></html>".getBytes();
mp.addBodyPart(new MimeBodyPart(htmlPartHeader, htmlPartData));
logger.debug("Sending status="+OK);
response.setStatus(OK);