Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
sr_c
3 years agoExplorer | Level 3
save_url throws error "request body: could not decode input as JSON"
Hi
I am trying to upload files (pictures with .jpg extension) to my dropbox account (to a specific app folder). I am using Airtable scripting (Javascript) extension to upload files from Airtable (...
- 3 years ago
sr_c wrote:...},data: filedata}...sr_c, When you are preparing a request body with appropriate data, you have to set those data. What actually is going on here? 🤔 You have already prepared request body (that you named as 'filedata' - incorrect name and probably confusing)! In this context instead of setting 'data', you have to set 'body'. 😉 Be more careful!
Hope this helps.
Greg-DB
Dropbox Community Moderator
3 years agosr_c As Здравко said, you'll need to make sure you're sending a JSON string. It doesn't look like you're doing so in your current code. We do recommend using the official Dropbox JavaScript SDK though, as it will do much of the work for you.
- sr_c3 years agoExplorer | Level 3
Hi
Based on the suggestion to use JSON.stringify, I tried to implement below solution but error remains same. Not sure whether this is the right way to implement the suggestion. Changes highlighted in blue
------------------------------------------------------------------------------------------
let appToken = "<<App Token>>"let fileobj = {"path":"/myairsri/best_peacock.jpg","url":urlval}let filedata = JSON.stringify(fileobj)// set up the post optionslet postOptions = {method: "POST",headers: {"Authorization" : "Bearer " + appToken,"Content-Type" : "application/json"},data: filedata}Please let me know your suggestionsThanks- Здравко3 years agoLegendary | Level 20
sr_c wrote:...},data: filedata}...sr_c, When you are preparing a request body with appropriate data, you have to set those data. What actually is going on here? 🤔 You have already prepared request body (that you named as 'filedata' - incorrect name and probably confusing)! In this context instead of setting 'data', you have to set 'body'. 😉 Be more careful!
Hope this helps.
- Greg-DB3 years ago
Dropbox Community Moderator
sr_c I see you're using fetch to perform the call, so make sure you're using the right options to construct the call as needed. As Здравко said, fetch expects a parameter named 'body' to set the request body, not 'data'.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
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!