我正在尝试实现如下代码所示的POST调用。
Map<String, String> header = {"Content-Type": "application/json"};
Map<String, String> body = {
"client_id": "xxxx",
"client_secret": "XXXX",
"password": "password",
"username": "username",
};
Future<Post> callForFirstToken() async {
final response = await http.post(url, headers: header, body: body);
return response.statusCode == 200
? Post.fromJson(json.decode(response.body))
: throw Exception('Failed to load ...');}
但是,我收到了这个错误:
Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:60556/sK_cPlYMcGQ=/ws
{HttpHeaders.contentTypeHeader: "application/json"}
。 - Chuck Batson