Skip to content
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

PATCH request overrides content type causing errors #203

Open
skatanski opened this issue Sep 5, 2024 · 0 comments
Open

PATCH request overrides content type causing errors #203

skatanski opened this issue Sep 5, 2024 · 0 comments

Comments

@skatanski
Copy link

Expected Behavior

Vault API Patch endpoint requires 'Content-Type: application/merge-patch+json' header, otherwise it fails with an error.
HashiCorp.Vault client has AsynchronousClient.PatchAsync method, which should run successfully, if HeaderParameters include Content-Type set to application/merge-patch+json.

Current Behavior

Currently ApiClient will overwrite content-type during patch call here:
https://github.com/hashicorp/vault-client-dotnet/blob/main/src/Vault/Client/ApiClient.cs#L466

Content-Type is initially loaded from HeaderParameters here: https://github.com/hashicorp/vault-client-dotnet/blob/main/src/Vault/Client/ApiClient.cs#L440 however its not really used in the case where PatchAsync method is called.

Failure Information

HashiCorp.Vault 0.3.0
net8.0

Steps to Reproduce

Following code will fail with the incorrect content type error, because the content type added through HeaderParameters is not used:

var data = "{ \"data\": { \"test\": \asdasdasd\" } }";
var requestOptions =  new RequestOptions { Data = data };
requestOptions.HeaderParameters.Add("Content-Type", "application/merge-patch+json");
await vaultClient.Secrets.AsynchronousClient.PatchAsync<T>(path, options);

Additional Information

It's quite visible from the NewRequest method where things go wrong. Its also visible in the documentation https://developer.hashicorp.com/vault/docs/commands/patch that specific content type is required for the method to succeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant