xUtils怎么post请求上传json数据

        InfoSmallCodeBinding smallCode = new InfoSmallCodeBinding();
        smallCode.setSmallCode("测试");
        smallCode.setMiddleBoxCode("测试");
        smallCode.setProductCode("0001");
        Gson gson3 = new Gson();

        String url = AppConfig.ApiUrl+"?action=smallcodebindingadd";
        HttpUtils httpUtils = new HttpUtils();
        //Log.d("Http2635", "test: "+gson3.toJson(smallCode));
        RequestParams params = new RequestParams();
        params.setBodyEntity(new StringEntity(gson3.toJson(smallCode),"UTF-8"));
        params.setContentType("application/json");
        httpUtils.send(com.lidroid.xutils.http.client.HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Log.d("Http2635", "onSuccess: "+responseInfo.result.toString());
                    }

                    @Override
                    public void onFailure(HttpException e, String s) {
                        Log.d("Http2635", "onFailure: "+e.toString());
                    }
                }
        );

 

posted @ 2017-11-18 17:17  _Vincent  阅读(2511)  评论(0编辑  收藏  举报