cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

StefanReeder
New member | Level 2

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:

image1.png

 

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:

image2.png

 

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

image3.png

 

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.

3 Replies 3

Greg-DB
Dropbox Staff

[Cross-linking for reference: https://stackoverflow.com/questions/64454739/using-server-side-ss2-x-to-upload-files-to-dropbox-body... ]

 

I can't offer help with the NetSuite side of things, as that's not made by Dropbox, but for reference, the /2/files/upload Dropbox API endpoint is a "content-upload" style endpoint, meaning it expects the file data in the HTTPS request body. The data should be sent just as a raw octet-stream (per the "Content-Type"), without any additional encoding. (Dropbox doesn't perform any additional operations, such as encoding/decoding, on the received data before storing it.)

 

So, for example, if your data source is giving you your file data encoded with base64 encoding, you may need to base64-decode it before sending it to Dropbox.

Anonymous One
Explorer | Level 4

Hi,

Did you find any solution to tackle this?

Greg-DB
Dropbox Staff

@Anonymous One I see you also posted your own thread, so we'll follow up with you there.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Anonymous One Explorer | Level 4
What do Dropbox user levels mean?