Upload file through NetSuite Suitelet script
Hi
I am new ot this. Is there anyone tried to upload file to folder on box via suitescript.
I am able to create folders and sub folders but finding some issues in converting curl to suitescript body object.
I want to convert this to suite script
I tried below but having issues and also can't find anything in suitescript documentation
curl https://upload.box.com/api/2.0/files/content \
-H "Authorization: Bearer ACCESS_TOKEN" -X POST \
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
-F file=@myfile.jpg
I have tried below but returning blank object
var obj = {
'attributes': '{"name":"Capture001.png", "parent":{"id":"removed for privacy23"}}',
};
//var sobj = JSON.stringify(obj)
nlapiLogExecution('DEBUG', "OBJ", JSON.stringify(obj));
var result = nlapiRequestURL(url, obj, BOX_AUTHORISATION, "POST");
-
Hello Box Team,
I've developed a NetSuite script1.0 to download and upload a file from BOX's folder.
(a) From Box to NetSuite I'm able to download file through NetSuite script using Box Api and working fine however
(b) I'm trying to upload file From NetSuite to Box's folder, always getting error response code-415 (i.e. Box Error: 'Unsupported Media Type).
Could you please check below codes and suggest the required modification in code?
function postFileNetSuiteS2BOX(boxFolderId, nsFileId, boxApiAccessToken)
{
var restUrl = 'https://upload.box.com/api/2.0/files/content/';
var restHeaders = new Array();
restHeaders['Content-Type']='multipart/form-data';
restHeaders['Authorization'] = 'Bearer ' + boxApiAccessToken;
var fileObj = nlapiLoadFile(nsFileId); //Load excell file
var fileURL = fileObj.getURL(); //file url of NetSuite file cabinet's folder
var nsFileType = fileObj.type;
var fileContent = fileObj.getValue(); //Content of excel file
var nsFileName = fileObj.getName(); //Name of excel file
var parent = { 'id': boxFolderId.toString()};
var attribs = { 'name' : nsFileNameStr.toString(), 'parent' :parent};
var body = { 'attributes' : attribs, 'file' : fileURL};
nlapiLogExecution('DEBUG', 'File Attributes', JSON.stringify(body));
var postReq = nlapiRequestURL(restUrl, body, restHeaders, null, "POST");
return postReq;
}Your quick response will highly apricated!
Thanks,
Shiv Rastogi
サインインしてコメントを残してください。
コメント
4件のコメント