I am not able to send my "multipart/form-data' file to this API. If I use POSTMAN it's working but with the https post method it seems that netsuite doesn't recognize the "form-data" content-type. Somebody knows how to send a form-data with SuiteScript 2 ? Here is a part of my code:
var fileObj = file.create({
name: invoiceNumber + '_ubl.xml',
fileType: file.Type.XMLDOC,
contents: einvoicecontentwithpdf,
folder : 120,
isOnline : false
});
var headers = {
'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'multipart/form-data'
};
var response = https.post({
url: 'https://community-api-uat-1-2.nxt.uat.unifiedpost.com/api/universal_connector/v1/uc/ar',
body: {
'file': fileObj
},
headers: headers
});
You have to build the whole body yourself.
This works as much as I've tested so far. Code may look a little non-idomatic because it's compiled from Typescript.
Note that to include non-text files this would have to be adapted to base64 encode the file bodies.
a simple test: