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 getting the following error: 'responseError in call to API function "files/move:2": request body: could not decode input as JSON'
I don't know if it has anything to do with the fact that the API body is supposed to be 'raw' format. I am not familiar with this format.
function moveDocWithinDB(dropboxAccessToken,ctrData){
Logger.log("Function moveDriverDoc ");
var raw = {
"from_path":"/Driver Shared Files/Anna/Andrew Walter- RMR Shared/(Paperwork)/TEST1234568_POD.pdf",
"to_path":"/Customer Delivery Orders/Active DO's/ABC Corp/TEST1234568_POD.pdf",
"allow_shared_folder": false,
"autorename": false,
"allow_ownership_transfer": false
}
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);
Logger.log("response" + response)
}
- ЗдравкоLegendary | 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.
- rubbermeetsrdExplorer | 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.
- ЗдравкоLegendary | 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? 🙂
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!