Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Since request package is depricated (https://www.npmjs.com/package/request ) I opt to use axios for interaction with Dropbox API.
I need to upload files from node.js server
I'm getting error "Request failed with status code 400". Here is my code. What I'm doing wrong?
const uploadToExternalService = async function uploadToExternalService(token, path, content) {
try {
let res = await axios({
url: 'https://api-content.dropbox.com/2/files/upload/',
method: 'post',
// timeout: 8000,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'text/plain'
},
body: content
})
if(res.status == 200){
// test for status you want, etc
console.log(res.status)
}
if(res.status == 400){
// test for status you want, etc
console.log(res)
}
// Don't forget to return something
return res.data
}
catch (err) {
console.error(err);
}
}
uploadToExternalService(SECRET_KEY, req.file.path, req.file).then(res => console.log(res));b
[ Cross-linking for reference: https://stackoverflow.com/questions/61291263/how-to-upload-file-to-dropbox-with-axios ]
What is in the response body for the 400 error response? It should contain a more specific and useful error message indicating what the issue is.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!