Ok. Maybe this GatewayScript snippet will be helpful.
var hm = require('header-metadata');
session.input.readAsBuffer(function (error, buffer) {
if (error)
{
// handle error
session.output.write (error.errorMessage);
} else {
//Create a boundary id, make sure that it isn't present in the payload
var boundary = "xyz123";
//Line break
var crlf = '\r\n';
//Create the multipart message payload
var multipart = '--' + boundary + crlf +
'Content-Type: text/plain' + crlf +
'Content-Disposition: form-data; name="jsontext"; filename="bulk.json"' + crlf + crlf +
buffer.toString() + crlf + '--' + boundary + '--' + crlf;
//Concatenate a new content-type header value
var contentType = 'multipart/form-data; boundary=' + boundary + ' type="text/plain"';
//Set the content type header created above
hm.current.set('Content-Type', contentType);
//Write payload into output
session.output.write(multipart);
}
});
#DataPower#Support#SupportMigration