我尝试了许多格式来传递flutter项目中的请求参数,但是我得到了API状态代码415和Unhandled Exception: FormatException: Unexpected end of input (at character 1)
。为了理解表单数据,我添加了邮递员图像。
发布于 2021-02-09 17:47:42
对于Flutter HTTP库,它是这样的,
var headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
var request = http.Request('POST', Uri.parse(''));
request.bodyFields = {
'firstName': 'Keval',
'lastName': 'ebiz',
'email': 'al@gmail.com',
'phone': '1234'
};
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
https://stackoverflow.com/questions/66115781
复制相似问题