RE: Has anyone in the NS developer world ever push/upload a csv file from external drive into Netsuite file cabinet using a RESTlet

I implemented (tried to) the  file-cabinet-api restlet (Tim D) and testing with Postman. My Tokens are good as I tested with a GET call using a simple Hello World function. When I try to use the fileCreate function in the restlet to upload a file from my local drive to the file cabinet, it fails. I used the Hello World example in the script, but no file was created. I tried fileGet and it didn’t work either.
I have searched and searched and it seems that no one has done this using a NS RESTlet.  I have successfully implemented an email capture plug-in that pushed a csv file into the File Cabinet, but when you have financial data, email is unacceptable.
Thanks for any help.  Since I’m new, I will continue to search this community.
soakes55 Rookie Asked on March 18, 2021 in SuiteScript.

If you can post sample code for your restlet, we can walk you through the suitescript to save the file to  the filecabinet.  You can also do this easily using suitetalk.

on March 21, 2021.

var file,log;

define( [ ‘N/file’, ‘N/log’], main );

function main( fileMod, logMod ) {

file = fileMod;
log = logMod;

return {
post: postProcess


function postProcess( request ) {

if ( ( typeof request.function == ‘undefined’ ) || ( request.function == ” ) ) {
return { ‘error’: ‘No function was specified.’ }

switch ( request.function ) {

case ‘fileCreate’:
return fileCreate( request )

var response = { ‘error’: ‘Unsupported Function’ }
return response;



function fileCreate( request ) {

// Load the file.

try {

var myfile = file.create(
fileType: request.fileType,
contents: request.contents,
description: request.description,
encoding: request.encoding,
folder: request.folderID


// Save the file and get its ID.
var fileID =;

// Load the file.
myfile = file.load( { id: fileID } );

// Create the response.
var response = {};
response[‘info’] = myfile;
response[‘content’] = myfile.getContents();

return response;

} catch (e) {
return { ‘error’: e }


on March 22, 2021.
Add Comment
2 Answers

Keep in mind this to create the file correctly, you can use the file.Type Enum to set the type as a CSV.
To create a CSV file you have to use the encoding of UTF8, you also can use the file.Encoding Enum to get the correct encoding constant.

    name: request.fileType ,
    fileType: file.Type.CSV,
    encoding: file.Encoding.UTF8

Rookie Answered on March 29, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.