flutter - http.post在flutter中返回307错误代码
问题描述
我正在使用 http 客户端进行颤振网络调用。
- 我要求邮递员得到正确响应,
- 但是在尝试使用 http.post 时,它会返回错误代码 307-Temporary Redirect,
方法体:
static Future<http.Response> httpPost(
Map postParam, String serviceURL) async {
Map tempParam = {"id": "username", "pwd": "password"};
var param = json.encode(tempParam);
serviceURL = "http:xxxx/Login/Login";
// temp check
Map<String, String> headers = {
'Content-Type': 'application/json',
'cache-control': 'no-cache',
};
await http.post(serviceURL, headers: headers, body: param).then((response) {
return response;
});
}
此外,相同的代码会返回对其他请求和 URL 的正确响应。首先,我尝试使用 Chopper 客户端,但遇到了同样的问题。
我无法从服务器端检测到该问题。
任何帮助/提示都会有所帮助
解决方案
尝试/
在serviceUrl
. 因此, serviceUrlserviceURL = "http:xxxx/Login/Login/"
代替serviceURL = "http:xxxx/Login/Login"
.
这对我有用。
推荐阅读
- java - 从文件中读取类的对象数组
- python - Python——获取排序列表中元素索引的有效方法,使用多个属性排序
- c - 在内核模块上获得正常运行时间?
- python - python中的圆括号或大括号中不存在逗号上的拆分字符串
- webassembly - 分布式普适计算中的 WebAssembly
- angular - ngSwitch 在评估为 true 时不显示项目
- r - R, rowMeans by Column in data.frame
- c# - Unity C# 对话显示,每个字母在下一个字母部署之前部署两次
- java - Java 中的 wait() 和 notify() 是如何工作的?
- sybase - 编写完整的 Sybase 数据库脚本