Pre-request script: send multipart/form-data

I am trying to fetch a file from box & then upload it another server. This complete process is being done in pre-request script. I was able to successfully get the file buffer from box but I am struck at uploading the file to another server,as I need to send the data as formdata which needs multipart boundary.

If I use postman to upload file, then boundary is automatically calculated by postam. How to calculate/prepare multipart form-data in pre-request script?

@vikasreddyCapb Welcome to the community :partying_face:

You can something like below:

const reqObj = {
    'method': 'POST',
    'url': '',
    'body': {
            'mode': 'formdata',
            'formdata': [
                {'key':'foo', 'value':'bar'},
                {'key':'bar', 'value':'foo'}
pm.sendRequest(reqObj, (error, response) => {
    if (error) throw new Error(error);

Postman will add the headers for “multipart/form-data” :slightly_smiling_face:

@bpricilla Thanks for your reply.

Unfortunately, the provided solution did not work as there was an error (API upload did not contain a file part).