Hi
I tried to call sharing/got_file_metadata with the admin id, and with "Dropbox-API-Select-Admin".
It failed and returned "invalid_file"
When I use the same file id with it's owner id, it works as it should.
This behavior contradicts the documention, wich clarifies that this EP supports Select-Admin with a "whole team" permission.
This is the code
#!/usr/bin/env python3
import requests
import json
URL = 'https://api.dropboxapi.com/2/sharing/get_file_metadata'
TOKEN = '****'
FILE_ID = '****'
OWNER_ID = '****'
ADMIN_ID = '****'
def do_request(member_id, as_admin):
select_header = "Dropbox-API-Select-Admin" if as_admin else "Dropbox-API-Select-User"
headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
select_header: member_id,
}
params = {
"file": FILE_ID,
# A list of `FileAction`s corresponding to `FilePermission`s that should appear in the
# response's SharedFileMetadata.permissions field describing the actions the authenticated user can perform on the file.
# get full list of actions https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata
"actions": [
"disable_viewer_info",
"edit_contents",
"enable_viewer_info",
"invite_viewer",
"invite_viewer_no_comment",
"invite_editor",
"unshare",
"relinquish_membership",
"create_link",
],
}
return requests.post(URL, data=json.dumps(params), headers=headers).text
print(do_request(OWNER_ID, False))
print(do_request(ADMIN_ID, True))
and this is the output:
{"access_type": {".tag": "owner"}, "id": "****", "name": "File2.pptx", "owner_team": {"id": "****", "name": "Polyrize"}, "path_display": "/File2.pptx", "path_lower": "/file2.pptx", "permissions": [{"action": {".tag": "edit_contents"}, "allow": true}, {"action": {".tag": "invite_viewer"}, "allow": true}, {"action": {".tag": "invite_viewer_no_comment"}, "allow": false}, {"action": {".tag": "invite_editor"}, "allow": true}, {"action": {".tag": "unshare"}, "allow": true}, {"action": {".tag": "relinquish_membership"}, "allow": false}, {"action": {".tag": "create_link"}, "allow": true}, {"action": {".tag": "disable_viewer_info"}, "allow": true}, {"action": {".tag": "enable_viewer_info"}, "allow": true}], "policy": {"member_policy": {".tag": "anyone"}, "resolved_member_policy": {".tag": "anyone"}, "acl_update_policy": {".tag": "editors"}, "shared_link_policy": {".tag": "anyone"}, "viewer_info_policy": {".tag": "enabled"}}, "preview_url": "https://www.dropbox.com/scl/fi/***", "time_invited": "2019-09-02T06:00:55Z"}
{"error_summary": "access_error/invalid_file/", "error": {".tag": "access_error", "access_error": {".tag": "invalid_file"}}}
Why does it happen? Thank you,
Nitay