为什么我在 Flutter 中收到 HTTPS 错误 BAD_REQUEST

问题描述

我在使用 HTTPS 时收到错误 400。但它对 HTTP 请求的响应非常完美。 我使用的是 dio 3.0.10 和 Flutter 1.22.6,服务器是 AWSELB/2.0。 这是代码

    dio http = dio();
    String url = 'https://HOST:PORT/PATH?queries';
    
    try {
        Response response = await http.get(
            url,options: Options(headers: {
                HttpHeaders.authorizationHeader: 'Bearer $token',})
        );

        if(response.statusCode == HttpStatus.ok)
            return response.data;
        else
            throw NetworkException('Something went wrong with suggestion fetching');
    } on dioError catch(e) {
        throw NetworkException('Something went wrong with suggestion fetching.');
    }

我也尝试过使用 POSTMAN 和 cURL,API 运行良好。但是使用 dio 发送时会发送 400 'Bad Request' 错误。我也尝试过其他库 http(0.13.0),在这里我也收到了 400 Bad Request。

我已尝试使用 Google Map API(HTTPS) 进行 dio。在那里我得到了很好的回应。我无法找出我做错了什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)