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.
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:
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.