How do I add http header attributes and values using the generated web api client
Closed this issue · 1 comments
asastry01 commented
Hello There, I need your help/advice. I have installed Connected Service tool on Visual Studio 2019 and followed your instructions to generate web Api client.
I was able generate the client successfully and was able to invoke the endpoint methods.
Now I have to pass HTTP headers to the end point, how can I set the values for each Header property without altering the generated code.
Thank you
-Arvin
unchase commented
Hi, @asastry01
For example,
...
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "<token>");
var apiClient = new Client("<api_base_uri>", httpClient);
var result = await apiClient.CallSomeFunctionAsync();
...
}
...