I / flutter(23942):DioError [DioErrorType.RESPONSE]:Http状态错误[500]

问题描述 投票:0回答:1

我在通过API进行身份验证或登录时遇到HTTP错误500。并且无法得到此错误。它之前运行良好,但是突然抛出了这个HTTP错误。

CODE:

Dio类的实例:

dio() {
    Dio dio = Dio();

    dio.options.connectTimeout = 60000; //5s
    dio.options.receiveTimeout = 60000;
    return dio;
  }

认证方式:

Future<Map> authenticate({@required String username, @required String password}) async{
   String url =  "https://.....";
   Response response;
   try{
     response =await dio().post(
       url,
       options: Options(
         contentType: ContentType.parse("application/x-www-form-urlencoded"),
       ),

       data: {
         'grant_type': 'password',
         'client_id':clientId,
         'client_secret':clientSecret,
         'username': username,
         'password': password,
       }
     );
     print("Authentication post response.dataaaaaa:${response.data}");
     return response.data;

   }catch(e){
     print("ERROR:$e");
     throw e;
   }
 }

在catch组中出错:

 DioError [DioErrorType.RESPONSE]: Http status error [500]
flutter dart http-error dio
1个回答
0
投票

HTTP状态码500表示您的API后端有问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.