Sorry to ask this question like this. I can give you the feeling I would like you to do the code for me. I already spent a day tying to write the code to send a http request that contains a header with versioning:
For versioning I use the versioning by Media Type from Microsoft/aspnet-api-versioning project.
My API part is working fine and I can request the correct version without problem with Postman:
You see this line "Content-Type = application/json;v=2.0"? On postman no problem. With HttpClient from C# impossible to do.
Let me copy pas here all solution I tried with they error. I will Edit this question each time I try a new solution. By facility, but also to be more clear I will copy paste images:
Solution 1: The extension method with new Content = ...
Solution 1B: From BeginnerTejas
Solution 1C: From BeginnerTejas but using MediaTypeWithQualityHeaderValue now
Solution 2: The extension method with request.Headers.Add(...)
Solution 3: BaseProxy with Client.DefaultRequestHeaders.TryAddWithoutValidation(...) It seems I cannot add any "Content-Type"
Solution 4: BaseProxy with Client.DefaultRequestHeaders.Accept.Add(...)
Solution 5: request.Headers.TryAddWithoutValidation("Content-Type", "application/json");