Python SDK question - folder.has_collaborators not found
AnsweredHello,
I am trying to determine with the Python SDK and Box API how to see if a file or folder is being shared. I looked at the Box documentation and there looks to be an attribute of the folder object called has_collaborators, but is not a valid parameter.
I looked over the BOX SDK docs and its says I can query the folder object with a string of parameters, but I didnt see a place where valid parameters were..
Things I do see, are name, owned_by, and item size, but I really need to know if a item is being shared.
How do I look at the parameters or attributes of a object collection? If i can just pprint it, that would have been awesome, but that alas doesnt work.
Thanks for the help,
Gary
-
The has_collaborators field on File and Folder objects is not returned from the API by default; you'll need to specifically request it. You can do this by passing a list of field names you want returned to the folder.get() method, like this:
folder = client.folder('FOLDER_ID').get(fields=['has_collaborators']) print('The folder {} collaborators'.format('has' if folder.has_collaborators else 'does not have'))
-
I clicked "Solution" too fast, this doesnt work.
I get this error:
AttributeError: 'Folder' object has no attribute 'has_collaborators'
if item.type == 'folder':
item_info = self.client.as_user(user).folder(folder_id=item_id).get(fields=['has_collaborators'])
if item.type == 'file':
item_info = self.client.as_user(user).file(file_id=item_id).get(fields=['has_collaborators'])
if item_info.has_collaborators:
shared=True
Please sign in to leave a comment.
Comments
4 comments