C# HttpClient, getting error Cannot add value because header 'content-type' does not support multiple values -
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 code. want post, , set content type text/html, when above error.
i can set content type seems via content.headers.contenttype
don't know how specifcy "text/html" if that. can help?
haven't got .net 4.5 ready, according httpcontentheaders.contenttype
, mediatypeheadervalue
, should this:
content.headers.contenttype = new mediatypeheadervalue("text/html");
Comments
Post a Comment