Flutter: One or more validation errors occurred in a get request with Basic Authentication authorization

Issue

This Content is from Stack Overflow. Question asked by Mona

I am working with basic authentication in a get request and it takes parameters, but it throws the following error as a status code and response body.

{“type”:”https://tools.ietf.org/html/rfc7231#section-6.5.1″,”title”:”One or more validation errors occurred.”,”status”:400,”traceId”:”00-5bebf6cfcb0e1cec5306c5dbff1cf6c0-c432aba0a422c830-00″,”errors”:{“password”:[“The password field is required.”],”user_name”:[“The user_name field is required.”]}}.

I don’t know what it means and what should I fix in my code. Can anybody help me, here is my code:

String basicAuth =
            'Basic ${base64.encode(utf8.encode('$_email:$encodedPassword'))}';

var queryParams = {
          'domain_name': 'domainName',
          'token': 12345.toString(),
        };
   final uri =
            Uri.https(baseUrl, '/api/Employee/validate_user', queryParams);

        final res = await http.get(uri, headers: {
          HttpHeaders.contentTypeHeader: 'application/json',
          HttpHeaders.authorizationHeader: basicAuth,
        });
        if (res.statusCode == 200) {

         debugPrint(res.body);

           }else {
          debugPrint("Status " + res.statusCode.toString());
          debugPrint(res.body);
        }



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?