We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

StefanReeder's avatar
StefanReeder
New member | Level 2
5 years ago

NetSuite Server Side SS2.x Script to upload files to Dropbox - body encoding issue

Hi team

 

I'm trying to upload a file to Dropbox via the API using a user event (server side) script in NetSuite.

 

I can get a file to be uploaded, but having an issue with the "body" encoding.

 

Thus far, my https request looks like:

 

URL and headers:

 

and the body is being set as follows:

 

var httpsRequest = {
                    method: https.Method.POST,
                    url: request.url,
                    headers: request.headers,
                    body : data.content,
                };

data.content is the file from the NS file cabinet, extracted with myfile.getContents().

 

 

When loading the file it looks like Base64.

 

I have also tried re-encoding the file contents to (UTF_8 to Base64), but the file is still unreadable when synced to the desktop.

 

If i do the request from Postman to Dropbox it works, then when I change the URL to a request.bin, the working "body" is structured like:

 

However, when coming from NetSuite, the same data looks like:

 

So I'm not sure how I set the "body" in my NetSuite request to be received in the same way?

 

Any help would be much appreciated, and save what little hair I have left.