I'm trying to list the folders for a team member on our Dropbox Business account.
https://api.dropboxapi.com/2/files/list_folder requires that we add the Dropbox-API-Select-User
header, but it does not seem to be working.
This is my code so far:
import requests
url = "https://api.dropboxapi.com/2/files/list_folder"
headers = {
"Authorization": "Bearer MY_TOKEN",
"Dropbox-API-Select-User": "dbid:ACCOUNT_ID"
}
data = {
"path": "/",
}
r = requests.post(url, headers=headers, json=data)
r.raise_for_status()
print(r.json())
Note that the json=
argument in the post()
function sets the content type to application/json
so that should be correct.
The code above raises an exception:
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.dropboxapi.com/2/files/list_folder
I have tried using the team member ID (bdmid:
) instead of the account ID but got the same error.
Do you have any idea what's wrong?
Thanks in advance for any help.
I'm using Python 3.6 if that makes any difference.