Hi I'm using Flurl and I need to set multiple headers for the post and the documentation on the site states to do await url.WithHeaders(new { h1 = "foo", h2 = "bar" }).GetJsonAsync();
I'm not sure what this means, what is H1, H2 ?
I'm trying to set Headers "API-VERSION:21" and "Authorization: askjdalksdjlaksjdlaksjd";
Use documentation (a very beautiful one): https://flurl.dev/docs/fluent-http/
// one:
await url.WithHeader("someheader", "foo").GetJsonAsync();
// multiple:
await url.WithHeaders(new { h1 = "foo", h2 = "bar" }).GetJsonAsync();
h1
and h2
are names of headers, and "foo"
and "bar"
are values.
As you can see you may also use call .WithHeader("headerName", "headerValue")
in your case:
.WithHeader("API-VERSION", "21")
.WithHeader("Authorization", "askjdalksdjlaksjdlaksjd")
In other words chain calls to send multiple headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With