Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add http header attributes and values using the generated web api client #42

Closed
asastry01 opened this issue Mar 10, 2021 · 1 comment
Labels
question Further information is requested

Comments

@asastry01
Copy link

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
Copy link
Owner

unchase commented Mar 12, 2021

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();
    ...
}
...

@unchase unchase added the question Further information is requested label Mar 12, 2021
@unchase unchase closed this as completed Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants