box / box-python-sdk-gen

Repository for generated Box Python SDK
Apache License 2.0
30 stars 5 forks source link

I have a question about metadata. #392

Closed c-rei closed 2 days ago

c-rei commented 3 days ago

I want to edit the metadata on my Box contents by our company users and collaborators which are external user. According to the SDK documentation, I can get and create the metadata instance by our company user with the code:

metadata = client.file_metadata.get_file_metadata_by_id( file.id, GetFileMetadataByIdScope.Enterpraise, "template10" ) metadata = client.file_metadata.create_file_metadata_by_id( file.id, CreateFileMetadataByIdScope.ENTERPRISE, "template10", { "filed": "aaaa", "filed1": 123, "field2": "2001-01-03T02:20:50.520Z", ...., }, )

I was wondering if our collaborators could edit the metadata, so I've tried these code:

metadata = client.file_metadata.get_file_metadata_by_id( file.id, "enterprise_eid", "template10" ) metadata = client.file_metadata.create_file_metadata_by_id( file.id, "enterprise_eid", "template10", { "filed": "aaaa", "filed1": 123, "field2": "2001-01-03T02:20:50.520Z", ...., }, ) I just changed a scope parameter with "enterprise_eid", the eid is our Box site EID. The results were successful. I referred to curl -i -X GET "https://api.box.com/2.0/files/12345/metadata/enterprise_27335/blueprintTemplate from the https://developer.box.com/reference/get-files-id-metadata-id-id/

My question is that is my approach correct?

Thanks any help.

Versions Used

Python SDK: 1.7.0 Python: 3.10.12

arjankowski commented 3 days ago

Hi @c-rei,

We are not the owner of the API only the SDKs, so our knowledge here might not be complete.

However, your approach seems to be correct. It is described here: https://developer.box.com/guides/metadata/scopes/

When accessing templates that belong to another enterprise - for example when accessing metadata on files belonging to other enterprises - the scope enterprise_ is used where is the ID of the enterprise the template belongs to.

Regards, Artur

c-rei commented 2 days ago

Hi, @arjankowski,

Thank you for your response, I am confident and do it. Regards, Rei