首页 > 解决方案 > http.post在flutter中返回307错误代码

问题描述

我正在使用 http 客户端进行颤振网络调用。

  1. 我要求邮递员得到正确响应,
  2. 但是在尝试使用 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 客户端,但遇到了同样的问题。

我无法从服务器端检测到该问题。

任何帮助/提示都会有所帮助

标签: flutter

解决方案


尝试/serviceUrl. 因此, serviceUrlserviceURL = "http:xxxx/Login/Login/"代替serviceURL = "http:xxxx/Login/Login".

这对我有用。


推荐阅读