Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is there a difference? #369

Open
c-rei opened this issue Nov 5, 2024 · 4 comments
Open

Why is there a difference? #369

c-rei opened this issue Nov 5, 2024 · 4 comments
Assignees
Labels
bug Something isn't working dontstale Mark issues not to be removed by stalebot

Comments

@c-rei
Copy link

c-rei commented Nov 5, 2024

When I get a folder information with "client.folders.get_folder_by_id(folder_id, fields=['name', 'path_collection'])", I can get a path_collection that is a FolderPathCollectionField object.

But when I get a subfolder information with "client.folders.get_folder_items(folder_id, fields=['name', 'path_collection'])", I got a path_collection that is a dict type. I known the subfolder is a FolderMini type.

So, when I treat a path_collection, I must distinct the folder type (FolderFull or FolderMini).
Or have any good way to treat them no need to judge them?

Thanks.

Versions Used

Python SDK: 1.7.0
Python: 3.10.12

@c-rei c-rei added the question Further information is requested label Nov 5, 2024
@lukaszsocha2
Copy link
Contributor

Hi,
the reason for this happening is that FolderMini doesn't have defined path_collection field and therefore when it arrives in the response from get_folder_items method, it is not deserialised to any object, but returned as a dict. We will make our effort to change the type of entries field in Items (https://developer.box.com/reference/resources/items/) to be either Folder or FolderFull. Both of them contain path_collection field.
In the meantime I advice you to make another get_folder_by_id call to get path_collection field - that way it will be always an object. Alternatively you can use raw_data field ro access full response as a dict.
Best,
@lukaszsocha2

@c-rei
Copy link
Author

c-rei commented Nov 5, 2024

Hi, @lukaszsocha2
Thanks for your response and advise.
Because I hove to treat a lot of items, so I want to reduce API calls as much as possible.
Then I still need to judge them when I use them.

Best,
@c-rei

@lukaszsocha2
Copy link
Contributor

lukaszsocha2 commented Nov 5, 2024

Hi @c-rei,
did you consider using raw_data as a temporary workaround? There it will be always a dict.

    root_folder: FolderFull = client.folders.get_folder_by_id('0')
    folder_items: Items = client.folders.get_folder_items(root_folder.id, fields=['path_collection'])
    for i, item in enumerate(folder_items.entries):
        print(folder_items.raw_data['entries'][i]['path_collection'])

Best,
@lukaszsocha2

@c-rei
Copy link
Author

c-rei commented Nov 6, 2024

Hi, @lukaszsocha2,
Surely, I should use raw_data, because not only path_collection, but also other fields, for example created_at etc.
The date type fields all are different (Datetime or ISO string).

Thanks a lot.
Best,
@c-rei

@lukaszsocha2 lukaszsocha2 added bug Something isn't working dontstale Mark issues not to be removed by stalebot and removed question Further information is requested labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dontstale Mark issues not to be removed by stalebot
Projects
None yet
Development

No branches or pull requests

7 participants