【发布时间】:2020-02-07 17:59:03
【问题描述】:
尝试发布此: {grant_type: 密码, 密码: 123456, 用户名: user1234} 使用以下代码
Future<HttpClientResponse> apiRequest(String url, String username, String password) async {
Map jsonMap = {'grant_type':'password','password':password,'username':username};
HttpClient httpClient = new HttpClient();
HttpClientRequest request = await httpClient.postUrl(Uri.parse(url));
request.headers.set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
request.add(utf8.encode((jsonMap.toString())));
print((jsonMap.toString()));
return await request.close();
}
但响应显示 {"error":"invalid_request","error_description":"缺少必需的 'grant_type' 参数。"}
在邮递员身上尝试得到不同的结果
【问题讨论】:
-
您确定响应来自请求,而不是来自颤振本身吗?