You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: