I am using flurl to submit HTTP request and this is very useful. Now I need to change the \"Content-Type\" header for some of the requests to \"appl
Am I allowed to post 3 answers to the same question? :)
Upgrade. Flurl.Http 2.0 includes the following enhancements to headers:
WithHeader(s)
now uses TryAddWithoutValidation
under the hood. With that change alone, the OP's code will work as originally posted.
Headers are now set at the request level, which solves another known issue.
When using SetHeaders
with object notation, underscores in property names will be converted to hyphens in the header names, since hyphens in headers are very common, underscores are not, and hyphens are not allowed in C# identifiers.
This will be useful in your case:
.WithHeaders(new {
x_ms_version = "2.11",
Accept = "application/json"
});