How to Upload Application/Binary Type Files from NetSuite to External Systems using SuiteScript 2.0

As a NetSuite developer, you must have come across situations where you needed to export or upload files from the NetSuite File Cabinet to an external system. For example, in a scenario where a customer wants to export their entire NetSuite CRM data (including message attachments) to an external server. Or for example, in a scenario where the customer wants to store their NetSuite documents on an external file sharing service like Dropbox.

External systems facilitate these types of file transfers by exposing their file upload APIs. These APIs require specific values for the HTTP Request Header fields such as Content-Type, Accept, etc. And these APIs are consumed by NetSuite’s SuiteScript APIs in order to send and receive the file data.

The latest APIs from external systems however require certain content types that are not supported by SuiteScript 1.0, which prevents you exporting those types from NetSuite. One example of such unsupported file types is application/binary files, which are not supported in SuiteScript 1.0. Luckily though, SuitScript 2.0 does support this file type, and you can use it to export application/binary files from NetSuite to any external system or application.

Here’s how you can do that.

1. Create a Suitelet in SuiteScript 2.0

2. Inside the SuiteScript 1.0 script, send a request to the Suitelet you just created, with the file’s id as a parameter. You can use nlapiRequestURL() to send this request

3. Then in the Suitelet you created, load File Content (as shown below)

var fileContent = file.load(fileId).getContents();

4. Then send the HTTP POST request to the External System API along with the required Content-Type header field value, and the File Content as the body of the request (as shown in the snippet below).

var externalSystemRequestObject = {

url: urlTOExternalSystemFileUploadApiEndpoint,

headers : {


Content-Type: ‘application/binary’


body: fileContent


Var externalSystemResponse =;

5. Next, send the external system’s response back to the caller script (as depicted below).


output: JSON.stringify(externalSystemResponse)



And that’s it. By using this approach, you can overcome the Content-Type limitation in SuiteScript 1.0 while leveraging the latest APIs from external systems.


You will need to have basic knowledge of SuiteScript 2.0 in order to perform this tutorial.

Have a NetSuite development requirement you would like discuss? Get In Touch.



It's only fair to share...Tweet about this on TwitterShare on LinkedInShare on Google+Share on Facebook
How to Use ExtJS Controls in NetSuite
SuitePromotions in NetSuite got “Sweeter”

Netsuite User

Leave a Reply

Your email address will not be published.