欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

HttpClient中异常 ‘The format of value ‘application/json;charset=UTF-8‘ is invalid.

程序员文章站 2022-06-22 17:06:01
...

具体原因参考于17036

四种HttpContext实例

MultipartFormDataContent : multipart/form-data

FormUrlEncodedContent : application/x-www-form-urlencoded

StringContent : application/json 等

StreamContent : binary


设置示例
 

var content = new StringContent(param, Encoding.UTF8, "application/json");
content.Headers.ContentType.CharSet = "UTF-8";

 

相关标签: 备忘录 c# http