cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: /2/files/get_metadata not returning all keys, e.g. sharing_info and parent_shared_folder_id

/2/files/get_metadata not returning all keys, e.g. sharing_info and parent_shared_folder_id

agarrkoch
Explorer | Level 4

Hi,

 

I need to use this endpoint to get the parent_shared_folder_id.

 

The problem is that my json data does not return this info. 

 

I get a response that looks like this:

{'.tag': 'file', 'name': 'testy2.png', 'path_lower': '/test/testy2.png', 'path_display': '/test/testy2.png', 'id': 'id:AYyyfCw5MFkAAAAAAABqCQ', 'client_modified': '2024-03-08T18:02:38Z', 'server_modified': '2024-03-08T18:02:39Z', 'rev': '61329ff5f6a802ad8828f', 'size': 1054078, 'is_downloadable': True, 'has_explicit_shared_members': False, 'content_hash': '7ae9e640d9ba9f51f129f57b67fdf1e5a22bd94c69f825ec5442e81080a6dca9'}

 

I'm running this request in python. 

 

 

import requests

# Define the endpoint URL
url = "https://api.dropboxapi.com/2/files/get_metadata"

# Replace '<get access token>' with your actual access token
access_token = 'ACCESS_TOKEN'

# Define the headers
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}

# Define the data payload
data = {
"include_deleted": True,
"include_has_explicit_shared_members": True,
"include_media_info": True,
"path": "/test/testy2.png"
}

# Make the POST request
response = requests.post(url, headers=headers, json=data)

# Print the response
print(response.json())
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff

The sharing_info field, e.g., from /2/files/get_metadata, is optional and only returned, "if this file is contained in a shared folder".

 

To turn a folder into a shared folder, so that you can then retrieve the shared folder ID like that and/or add members to it, you would use the /2/sharing/share_folder endpoint (or share the folder manually via the Dropbox web site).

View solution in original post

3 Replies 3

agarrkoch
Explorer | Level 4

Hi,

 

So I'm seeing the problem. You only get a shared_folder_id returned to you if at least one person has been shared the folder. 

 

I want to get the shared_folder_id so I can add members to a folder (per API specifications, I need to pass this id). The problem is that if I have no preexisting members for a folder, then I can't get the shared_folder_id. So I'm in a chicken-or-the-egg situation. 

 

How do I work around this??

Greg-DB
Dropbox Staff

The sharing_info field, e.g., from /2/files/get_metadata, is optional and only returned, "if this file is contained in a shared folder".

 

To turn a folder into a shared folder, so that you can then retrieve the shared folder ID like that and/or add members to it, you would use the /2/sharing/share_folder endpoint (or share the folder manually via the Dropbox web site).

agarrkoch
Explorer | Level 4

Thanks! I wasn't aware of the share_folder endpoint.

Need more support?