CodexBloom - Programming Q&A Platform

OCI SDK for Python: how to to Retrieve Object Metadata from Object Storage

👀 Views: 57 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
oracle-cloud-infrastructure oci-sdk object-storage Python

I've hit a wall trying to I'm collaborating on a project where I'm currently working on a project using the OCI SDK for Python (version 2.21.0) where I need to retrieve metadata for files stored in OCI Object Storage. Despite following the documentation, I keep working with the following behavior when executing my code: ``` oci.exceptions.ServiceError: (404, 'Not Found', 'The specified object does not exist.') ``` Here's the code snippet I'm using to retrieve the metadata: ```python import oci config = oci.config.from_file() # Load default config object_storage_client = oci.object_storage.ObjectStorageClient(config) namespace_name = 'my_namespace' bucket_name = 'my_bucket' object_name = 'my_file.txt' try: response = object_storage_client.get_object(namespace_name, bucket_name, object_name) print("Metadata:", response.headers) except oci.exceptions.ServiceError as e: print("behavior occurred:", e) ``` I verified that the `namespace_name`, `bucket_name`, and `object_name` are correct and that the object exists in the specified bucket. I've also checked the permissions for the Object Storage bucket and ensured that the user has the appropriate permissions to access the objects. However, the behavior continues. Additionally, I tried retrieving the object using the OCI Console, and it works fine, which makes me think there might be something wrong in my SDK usage or configuration. Has anyone experienced similar issues, or can someone provide insight into what I may be missing that would lead to this 404 behavior? My development environment is Debian. Any examples would be super helpful. I'm using Python 3.9 in this project. For context: I'm using Python on CentOS. What's the best practice here?