颤振错误:ErrorDioError [DioErrorType.RESPONSE: Http状态错误[400].<



我有一个小部件,采取附件名称和日期选择器与开始日期和结束日期和上传按钮上传附件,当我完成上传和定义日期,并单击按钮保存我得到与dio错误响应的消息,我该怎么办?

Dio dio = new Dio();
Response response = await dio
.post(BaseUrl + AppPaths.AddAttachments,
data: formData,
options: Options(
method: 'POST',
responseType: ResponseType.json,
headers: {HttpHeaders.authorizationHeader: 'Bearer $token'},
))
.then((value) {
print({"response:" + value.toString()});
if (value.statusCode == 200) {
print("Done");
print("response.statusCode");
print(value.statusCode);
setState(() {
_isLoading = false;
});
Navigator.pop(context);
} else {
print("Failed");
print("response.statusCode");
print(value.statusCode.toString());
setState(() {
_isLoading = false;
});
}
}).catchError((onError) {
print("on Error" + onError.toString());
setState(() {
_isLoading = false;
});
});
}

带有错误的图片

您是否尝试通过Postman测试API ?

代码400表示出错:https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

相关内容

  • 没有找到相关文章