来自android的网络请求导致抖动问题

时间:2020-04-29 06:18:24

标签: http flutter dio flutter-http

String b64Login = Base64.encodeToString(("loginid" + ":" + "password").getBytes(), Base64.NO_WRAP | Base64.URL_SAFE);
                HttpClient mHttpClient = new DefaultHttpClient();
                String APILink = "";
                APILink = _apiLink + "test/User/Signin";
                HttpPost mHttpPost = new HttpPost(APILink);
                mHttpPost.addHeader("Accept", "application/json");
                mHttpPost.addHeader("Content-Type", "application/json");
                mHttpPost.addHeader("key", _DataBaseKey);
                mHttpPost.addHeader("app", "6289");
                mHttpPost.addHeader("Authorization", "Basic " + b64Login);
                ArrayList<NameValuePair> nvArray = new ArrayList<>();
                nvArray.add(new BasicNameValuePair("Browser", Build.BRAND));
                nvArray.add(new BasicNameValuePair("IsMobile", "true"));
                nvArray.add(new BasicNameValuePair("Platform", Build.DEVICE));
                nvArray.add(new BasicNameValuePair("IPAddress", Build.ID));
                nvArray.add(new BasicNameValuePair("SessionId", Build.MODEL));
            try {
                mHttpPost.setEntity(new UrlEncodedFormEntity(nvArray));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

当我在Web api中应用不带nvArray列表的发布请求时遇到问题ApiAuthenticationFilter不允许在我评论ApiAuthenticationFilter时接受它,如何在需要纠正的情况下将URL加密为base64,我需要纠正我有一个android的经验现在我在flutter中也面临着同样的问题,我已经在android代码上面附加了它,可以正常工作,但是如何在flutter中做到这一点,请提出建议。

String b64Login = base64.encode(utf8.encode(loginId+":"+password);
  String mAPILink = Const.API_PATH + "test/User/Signin";
  var queryParameters =
  {"Accept" : "application/json", "Content-Type" : "application/json", "key" : apiKey, "app" : "6289", "Authorization" : "Basic " + b64Login};
  Response response;
  Dio dio = new Dio();
  response = await dio.post(mAPILink, data: queryParameters);
  print(response.statusMessage);

0 个答案:

没有答案