-
Notifications
You must be signed in to change notification settings - Fork 268
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
How to add headers to ContainerClient
requests?
#2254
Comments
A number of things from the previous unofficial versions of the client haven't quite made it over yet, and this is one of them. We'll be adding specific options as we continue, but for now, using a Every method takes an "Options" value as it's final parameter, and every pub struct IfMatch(String);
let context = Context::new().with_value(IfMatch(etag));
container_client.upsert_item(..., ItemOptions {
method_options: ClientMethodOptions {
context,
..Default::default()
},
..Default::default()
}).await; And then in your policy: if let Some(IfMatch(if_match)) = ctx.value::<IfMatch>() {
// Add your header here
} This is definitely a bit clunky and not the long-term plan, but if you'd like to move to |
Thank you @analogrelay! This unblocks me. I appreciate the support. |
Hi @kate-goldenring. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation. |
I am looking to implement compare-and-swap functionality with the new v0.22.0 CosmosDB SDK. With the previous
v0.21.0
SDK (example), i was able to use theif_match_condition(azure_core::request_options::IfMatchCondition::Match(etag))
method on theDocumentClient
. That client has been replaced by theContainerClient
in thev0.22.0
SDK, which is missing many methods for adding headers to requests. What is the best way to add a header (such as the"if-match"
one) to an individual request issued by theContainerClient
? I created a policy for the cases I wanted to add headers for all requests; however, I am not sure how to add headers on individual requests like i used to be able to with the predefined methods.The text was updated successfully, but these errors were encountered: