Flutter篇 http设置“content-type“: “application/json“会出现报错Cannot set the body fields of a Request ...
在flutter中在http请求发送时设置"content-type": "application/json"会出现报错Cannot set the body fields of a Request with content-type “application/json”解决方法通过jsonEncode处理要提交的参数final putData = jsonEncode(params); /
·
在flutter中在http请求发送时设置"content-type": "application/json"会出现报错Cannot set the body fields of a Request with content-type “application/json”
解决方法
通过jsonEncode处理要提交的参数
final putData = jsonEncode(params); // 处理提交参数
final putResponse = await http.put('http://192.168.201.21/user/modifyUser',
body: putData,
headers: {"token": userBasicsInfo.userTokenResult,"content-type": "application/json"}
).then((response){
var backResult;
if(response.statusCode == 200){
。。。。。。
}else{
print('数据请求错误:${response.statusCode}');
}
return backResult;
});
更多推荐
已为社区贡献3条内容
所有评论(0)