Setting custom headersΒΆ

The Python SDK uses the Requests library to make calls to Oracle Cloud Infrastructure services. If you need to add custom headers to your calls, you can do so via modifying the underlying Requests Session object

import oci

config = oci.config.from_file()
compute = oci.core.ComputeClient(config)

# Adds my-custom-header as a header in the request. This header will be included in ALL
# subsequent calls made
compute.base_client.session.headers['my-custom-header'] = 'my custom header value'

# If you no longer want to send the header then remove it from the dictionary
compute.base_client.session.headers.pop('my-custom-header')