I'm working in a code developed by someone else and I found this lines
HttpResponseMessage response = await Client.PostAsJsonAsync($"User", user);
coming from System.Net.Http.HttpClientExtensions
The code also use many similar methods likes:
Task<HttpResponseMessage> GetAsync(string requestUri);
Task<HttpResponseMessage> PostAsync(string requestUri, HttpContent content);
Task<HttpResponseMessage> PutAsync(string requestUri, HttpContent content);
Task<HttpResponseMessage> DeleteAsync(string requestUri);
coming from System.Net.Http.HttpClient
But I also need to send value in header (for versioning) so I modified my GetAsync by
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, $"User/{name}");
request.Headers.Add("ContenT-Type", "application/json;v=2.0");
HttpResponseMessage response = await Client.SendAsync(request);
I don't know if this is correct. Is there a way I can continue to work with get, post, update, postAsJson by setting my header or I'm force to use this generic send version?