1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
99 views
by brandon-w-8204 (34.1k points)
I see the new MultiPart Builder in the 25.2 release. How do I use it?

1 Answer

0 votes

//Create a multi part builder
var multiPart = qie.getMultipartBuilder(qie.getUUID(true));

//Add parts to the multi part builder
qie.addMultipartContentText(multiPart, 'textPart1', 'content 1');
qie.addMultipartContentText(multiPart, 'textPart2', 'content 2');
qie.addMultipartContentText(multiPart, 'textPart3', 'content 3');
qie.addMultipartContentBinary(multiPart, 'binaryPart1', qie.readFile('somelocalpath/report.pdf'), 'application/pdf', 'report.pdf');

// call the ws-connection that is ready to receive this request
var parameterMap = qie.newParameterMap();
var urlTemplate = qie.evaluateTemplate(qie.getWsEndpointUrl("{ws-connection}"));
var value = qie.callRESTWebService(
   "{ws-connection}",
   urlTemplate,
   "POST",
   multiPart,
   'multipart/form-data',
   parameterMap,
   60000);


//This code will debug out the boundaries if you need or want to see them.
var entity = multiPart.build();
var outputStream = new java.io.ByteArrayOutputStream();
entity.writeTo(outputStream);
var entityString = outputStream.toString("UTF-8");
qie.debug(entityString);

by brandon-w-8204 (34.1k points)
...