C# HttpClient, getting error Cannot add value because header 'content-type' does not support multiple values

c#

Solution

Haven't got .NET 4.5 ready, but according to `HttpContentHeaders.ContentType` and `MediaTypeHeaderValue`, it should look something like this:

content.Headers.ContentType = new MediaTypeHeaderValue("text/html");

Problem

``` HttpClient serviceClient = new HttpClient(); serviceClient.DefaultRequestHeaders.Add("accept", "Application/JSON"); HttpContent content = new StringContent(text); content.Headers.Add("content-type", "text/html"); var response = await serviceClient.PostAsync(new Uri(_serviceUrl), content); ``` This is my code. I want to do a POST, and set the content type to text/html, but when I do this I get the above error. I can set the content type it seems via `content.Headers.ContentType` but I don't know how to specifcy "text/html" if I do that. Can anyone help?

Original source