I am trying to upload a PDF in my javascript file but i get server response error code 500. I also need to find what i have to put in the body to upload the pdf file (using netsuite so i cant use the dropbox-sdk). I am now encoding my pdf from Base64 (that is what it is on my server) and outputEncoding is UTF-8 does this work>
function uploadFile(key, path, file) {
var URL = 'https://content.dropboxapi.com/2/files/upload';
//converting my file from base_64 to UTF_8
var body = encode.convert({
string: file,
inputEncoding: encode.Encoding.BASE_64,
outputEncoding: encode.Encoding.UTF_8
});
//header for Dropbox
var headers = {
"Authorization": 'Bearer '+ key,
"Dropbox-API-Arg":{"path":"/home/1.pdf","mode":"add","autorename":true,"mute":false,"strict_conflict":false},
"Content-Type": "application/octet-stream",
};
//netsuite specific
log.debug({
title: "debug",
details: body
});
//the post to https
var response = https.post({
url: URL,
body: body,
headers: headers
});
//below function is netsuite specific
log.debug({
title: 'Dropbox server response',
details: JSON.stringify(response)
});
}