Is it possible to set different custom headers on a per request basis? #3353
-
It is possible to add custom headers to requests, as described here: https://stackoverflow.com/questions/65332880/aws-boto3-chime-client-send-x-amz-chime-bearer-header However, I'd like to set these headers based on additional arguments that I pass to a put_object() call on a bucket resource for example. I tried passing these additional arguments as extra kwargs, but then I get an error about the kwargs being unknown. What I want to do:
However, this results in the following error:
This is not a limitation of python. Adding custom kwargs at runtime normally works. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @Frederik-Baetens , thanks for reaching out. It looks like there's already a feature request open in boto/botocore#2050 where you also made a comment. Before I follow up on the feature request, I'd like to suggest checking out these resources below:
Please let me know if any of this resolves the issue! |
Beta Was this translation helpful? Give feedback.
-
I haven't had time to validate this, but I think this might be possible with the botocore event system today. You'd have to hook into two events:
We currently have an in-progress PR with much improved documentation for the botocore events system that may help find the right combination of events to achieve this: #3686 |
Beta Was this translation helpful? Give feedback.
I haven't had time to validate this, but I think this might be possible with the botocore event system today. You'd have to hook into two events:
custom_arg
from the list and store it in the request context object. This way you can pass it as additional kwarg toget_object
as you propose without having it fail validation or cause errors during request serialization.