I use flurl to send an HTTP request and this is very useful. Now I need to change the Content-Type header for some requests "application / json; odata = verbose
public async Task<Job> AddJob()
{
var flurlClient = GetBaseUrlForGetOperations("Jobs").WithHeader("Content-Type", "application/json;odata=verbose");
return await flurlClient.PostJsonAsync(new
{
}).ReceiveJson<Job>();
}
private IFlurlClient GetBaseUrlForOperations(string resource)
{
var url = _azureApiUrl
.AppendPathSegment("api")
.AppendPathSegment(resource)
.WithOAuthBearerToken(AzureAuthentication.AccessToken)
.WithHeader("x-ms-version", "2.11")
.WithHeader("Accept", "application/json");
return url;
}
You can see how I tried to add the title above ( .WithHeader("Content-Type", "application/json;odata=verbose"))
Unfortunately, this gives me the following error:
"InvalidOperationException: invalid header name. Headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects."
I also tried flurl "ConfigureHttpClient", but could not find how / where to set the content type header.