I want to retrieve Dropbox files from Google Apps Script.

Asked 2 years ago, Updated 2 years ago, 53 views

I would like to get a list of Dropbox files from Google Apps Script and insert them into Spreadsheet.
I used the following HTTP request for Dropbox API:
An error will be returned.
It seems that the content of the body is not JSON.
Where is the problem?

return UrlFetchApp.fetch(
    "https://api.dropboxapi.com/2/files/list_folder",
    {
      "Content-Type": "application/json",
      "method": "post",
      "headers": {
        "Authorization": "Bearer (TOKEN),
        "Content-Type": "application/json"
      },
      "body": {
        US>"path": "
      },
      "muteHttpExceptions"—false
    }
  );

Error in call to API function "files/list_folder":request body:could not decode input as JSON

google-apps-script dropbox

2022-09-30 19:26

1 Answers

Looking at Dropbox API reference, I think the JSON string is specified in the main body of the HTTP request, so I think I should string it as follows and give it to you. Try it.

return UrlFetchApp.fetch(
    "https://api.dropboxapi.com/2/files/list_folder",
    {
      "Content-Type": "application/json",
      "method": "post",
      "headers": {
        "Authorization": "Bearer (TOKEN),
        "Content-Type": "application/json"
      },
      // Convert the JavaScript object to a JSON string.
      'payload': JSON.stringify({
        US>"path": "
      }),
      "muteHttpExceptions"—false
    }
  );


2022-09-30 19:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.