You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
rubbermeetsrd
3 years agoExplorer | Level 3
Javascript responseError in call to API function "files/move:2"
I'm working on a google app script to move a pdf file from one folder in Dropbox to another. I have it working in Postman but am having trouble getting it to work in my google app script. I am gett...
Здравко
3 years agoLegendary | Level 20
rubbermeetsrd wrote:... I am getting the following error: 'responseError in call to API function "files/move:2": request body: could not decode input as JSON'
var headers= {"Content-Type": "application/json", <<<<<<"Authorization": "Bearer "+ dropboxAccessToken,}var options = {method: 'POST',headers: headers,data: raw, <<<<<<<<<<<<muteHttpExceptions: true,};var response = UrlFetchApp.fetch(apiUrl, options);...
Hi rubbermeetsrd,
🙂 What are you expecting? You correctly declared "application/json" format, but by default how fetch is formatting the passed map? 🤔 Isn't it a form encoding? 😉
Hope this gives direction.
- rubbermeetsrd3 years agoExplorer | Level 3
What am I expecting? I am expecting the pdf file to move from one folder to another which it does in Postman.
In Postman, the body format is raw. I am not familiar enough with fetch calls to say whether they are encoded forms or not. This is the API call working in Postman (access token is whited out). When I brought up the move_v2 api call, the template was set up as a raw body which worked.
- Здравко3 years agoLegendary | Level 20
rubbermeetsrd wrote:... When I brought up the move_v2 api call, the template was set up as a raw body which worked.
...
I don't know what you mean 'raw body', but your 'template' seems correct. It should work. Why are you NOT calling 'move_v2' in the same way? 🤷 Take a look on your OP. Is it the same or not exactly? 🙂
- Greg-DB3 years agoDropbox Staff
rubbermeetsrd The /2/files/move_v2 endpoint is an "RPC" style endpoint, meaning it expects the parameters as JSON in the request body. The "request body: could not decode input as JSON'" error you're getting indicates that the request body did not contain valid JSON, and so the Dropbox API was unable to understand it.
You'll need to debug your code to make sure you're sending valid JSON in the request body. As Здравко noted, make sure you check which code you're running, as the code in your screenshot does not match the code in your original post. Specifically, one does convert the parameters to JSON using JSON.stringify, and one does not.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days agoIf 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 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!