I'm using WebClient and I set the headers to JSON yet when I look at Fiddler, it shows text/plain. I do not understand why. I have to use WebClient (older app).
How do I enforce JSON to be sent in the request as Content-Type?
My relevant code:
var webClient = new WebClient();
webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json; charset=utf-8");
webClient.Headers.Add("cache-control", "no-cache");
webClient.Headers.Add("Bearer", token);
//further down to the call...
var content = JsonConvert.SerializeObject(request).Replace(@"\", @"");
var jsonResponse = webClient.UploadString($"https://{APIHost}{APIAddress}", content.ToString());
question from:
https://stackoverflow.com/questions/65925984/using-webclient-keeps-changing-json-to-text-plain-for-content-type 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…