[英]Unable to catch dioerror [dioerrortype.response]: http status error [statusCode]
dioerror [dioerrortype.response]: http status error [statusCode] dioerror [dioerrortype.response]:http 状态错误 [statusCode]
Here is the Headers part :这是标题部分:
Headers("Authorization": "token",
"Content-Type" : "multipart/form-data",
"Accept" : "application/json")
Here is The Data part :这是数据部分:
try {
FormData data = FormData.fromMap({
"username": userName.toString(),
"name": naMe.toString(),
"birthday": birthDay.toString(),
"about": aboutUser.toString(),
"sender": sendUser.toString(),
"mobile": userMobile.toString(),
"avatar": _image != null
? await MultipartFile.fromFile(_image.path,
filename: avatarName.toString())
: Text('Invalid Avatar'),
});
}
Here is Dio request/response part :这是 Dio 请求/响应部分:
try {
Dio dio = Dio();
dio.options.headers['Accept'] = "multipart/form-data";
dio.options.headers['Authorization'] = "Bearer $token";
dio.options.headers['Content-Type'] = "application/json";
var response = await dio.post(url, data: data);
final res = json.encode(response.data);
print('$res');
var responseCode = response.statusCode;
print('$responseCode');
}
The problem was solved by editing catch blog with该问题已通过编辑 catch 博客解决
On DioError catch (error) {
var statusCode = error.response.statusCode;
Print(statusCode);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.