<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic sharing/get_file_metadata fails for admin in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/364550#M20702</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I tried to call sharing/got_file_metadata with the admin id, and with "Dropbox-API-Select-Admin".&lt;/P&gt;
&lt;P&gt;It failed and returned "invalid_file"&lt;/P&gt;
&lt;P&gt;When I use the same file id with it's owner id, it works as it should.&lt;/P&gt;
&lt;P&gt;This behavior contradicts the documention, wich clarifies that this EP supports Select-Admin with a "whole team" permission.&lt;/P&gt;
&lt;P&gt;This is the code&lt;/P&gt;
&lt;PRE&gt;#!/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))&lt;/PRE&gt;
&lt;P&gt;and this is the output:&lt;/P&gt;
&lt;PRE&gt;{"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"}}}&lt;/PRE&gt;
&lt;P&gt;Why does it happen? Thank you,&lt;/P&gt;
&lt;P&gt;Nitay&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2019 06:09:24 GMT</pubDate>
    <dc:creator>NitayBachrach</dc:creator>
    <dc:date>2019-09-12T06:09:24Z</dc:date>
    <item>
      <title>sharing/get_file_metadata fails for admin</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/364550#M20702</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I tried to call sharing/got_file_metadata with the admin id, and with "Dropbox-API-Select-Admin".&lt;/P&gt;
&lt;P&gt;It failed and returned "invalid_file"&lt;/P&gt;
&lt;P&gt;When I use the same file id with it's owner id, it works as it should.&lt;/P&gt;
&lt;P&gt;This behavior contradicts the documention, wich clarifies that this EP supports Select-Admin with a "whole team" permission.&lt;/P&gt;
&lt;P&gt;This is the code&lt;/P&gt;
&lt;PRE&gt;#!/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))&lt;/PRE&gt;
&lt;P&gt;and this is the output:&lt;/P&gt;
&lt;PRE&gt;{"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"}}}&lt;/PRE&gt;
&lt;P&gt;Why does it happen? Thank you,&lt;/P&gt;
&lt;P&gt;Nitay&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 06:09:24 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/364550#M20702</guid>
      <dc:creator>NitayBachrach</dc:creator>
      <dc:date>2019-09-12T06:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: sharing/get_file_metadata fails for admin</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/364559#M20705</link>
      <description>&lt;P&gt;Can you clarify where you see "the documention, wich clarifies that this EP supports Select-Admin with a "whole team" permission"?&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata" target="_self"&gt;documentation for&amp;nbsp;/2/sharing/get_file_metadata&lt;/A&gt; lists "User Authentication, Dropbox-API-Select-Admin (Team Admin)" under "AUTHENTICATION".&lt;/P&gt;
&lt;P&gt;That's indicating only support for the "Team Admin", not "Whole Team" &lt;A href="https://www.dropbox.com/developers/documentation/http/teams#teams-member-file-access" target="_self"&gt;mode&lt;/A&gt;. The description of the Team Admin mode is "The endpoint can access content of team folders but not team member's private files", which seems to match the behavior you're seeing.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 15:45:38 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/364559#M20705</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-09-11T15:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: sharing/get_file_metadata fails for admin</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/365103#M20721</link>
      <description>&lt;P&gt;Oh yes you are right, I looked at "get_metadata" which is has a whole team permission (Is there a reason for the inconsistenty of those permissions?).&lt;/P&gt;&lt;P&gt;But now I have the following problem:&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/env python3
import requests
import json
from pprint import pprint

URL_FOLDER = 'https://api.dropboxapi.com/2/sharing/get_folder_metadata'
URL_FILE = 'https://api.dropboxapi.com/2/files/get_metadata'
TOKEN = '***-****'
FILE_ID = 'id:'
ADMIN_ID = 'dbmid:'

def do_request_file(member_id):
    headers = {
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
        "Dropbox-API-Select-Admin": member_id,
    }

    params = {
        "path": FILE_ID
    }
    r = requests.post(URL_FILE, data=json.dumps(params), headers=headers).text
    return json.loads(r)

def do_request_folder(member_id, folder_id):
    headers = {
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
        "Dropbox-API-Select-Admin": member_id,
    }

    params = {
        "shared_folder_id": folder_id
    }
    r = requests.post(URL_FOLDER, data=json.dumps(params), headers=headers).text
    return json.loads(r)


metadata = do_request_file(ADMIN_ID)
pprint(metadata)
pprint(do_request_folder(ADMIN_ID, metadata["sharing_info"]["parent_shared_folder_id"]))&lt;/PRE&gt;&lt;P&gt;returns:&lt;/P&gt;&lt;PRE&gt;{'.tag': 'file',
 'client_modified': '2019-09-05T09:12:38Z',
 'content_hash': 'ccae535b5ac41d418b23187d9517ba652361bb9463e6b39e66f4e315bb21c910',
 'id': 'id:*******',
 'is_downloadable': True,
 'name': 'File2.pptx',
 'parent_shared_folder_id': '6201828192',
 'rev': '******',
 'server_modified': '2019-09-05T09:12:38Z',
 'sharing_info': {'modified_by': 'dbid:*****',
                  'parent_shared_folder_id': '6201828192',
                  'read_only': False},
 'size': 29445}
{'error': {'.tag': 'invalid_id'},
 'error_summary': 'invalid_id/.',
 'user_message': {'locale': 'en', 'text': 'Invalid shared folder ID.'}}&lt;/PRE&gt;&lt;P&gt;Even though team admin is accessible to folders&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2019 08:02:43 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/365103#M20721</guid>
      <dc:creator>NitayBachrach</dc:creator>
      <dc:date>2019-09-15T08:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: sharing/get_file_metadata fails for admin</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/365348#M20726</link>
      <description>&lt;P&gt;Thanks for following up, and apologies for the confusion. Looking at this, I believe you're running in to a particular edge case, where the field names can be misleading.&lt;/P&gt;
&lt;P&gt;The file for which you're getting the metadata in the first call is actually in a (different member's) home namespace, not a shared folder. Due to some implementation details though, that user's home namespace information is being returned in the file metadata as if it were a shared folder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, the sharing endpoint in the second call is rejecting the ID since it's not technically a shared folder ID.&lt;/P&gt;
&lt;P&gt;If you want to get the metadata for that parent folder, you can do so by calling&amp;nbsp;/2/files/get_metadata for that namespace under that team's root namespace. Here's what that would look like in this particular case, in curl:&lt;/P&gt;
&lt;PRE&gt;curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
    --header "Authorization: Bearer TOKEN_HERE" \
    --header "Dropbox-API-Select-Admin: ADMIN_ID_HERE" \
    --header "Content-Type: application/json" \
    --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "TEAM_SPACE_ROOT_ID_HERE"}' \
    --data "{\"path\": \"ns:6201828192\"}"&lt;/PRE&gt;
&lt;P&gt;Check out &lt;A href="https://www.dropbox.com/developers/reference/namespace-guide" target="_self"&gt;the Namespace Guide&lt;/A&gt; for more information on how this works, and for information on how to get the team space root ID and how to use the&amp;nbsp;'Dropbox-API-Path-Root' header.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 16:21:21 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/sharing-get-file-metadata-fails-for-admin/m-p/365348#M20726</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2019-09-16T16:21:21Z</dc:date>
    </item>
  </channel>
</rss>

