I want to add a dynamic header while making a Refit client call.
This is my refit client code, I am using refit via dependency injection instead of RestService.
[Post("/some-url/")]
Task<ApiResponseMessage<SomeResponseModel>> GetSomething(
SomeRequestModel request,
[Header("sessionKey")] string sessionKey,
CancellationToken cancellationToken = default);
This code does not adds the header, while if I use an delegating handler then it works.
I want to go this way because I need sessionKey
in response as well if I go with delegating handler I can't get key in response.
This is how I am calling it
await _serviceApi.GetSomething(command, sessionIdEncryptedValue, ct)
Can anyone tell what am I missing here?