android Volley GET方法与HashMap参数

时间:2017-08-10 10:56:23

标签: android get android-volley

我正在使用volly进行webservice调用 我的方法如下

 Map<String, String> MyData = new HashMap<String, String>();
        MyData.put(pam1, parm1value);


        JSONObject parameters = new JSONObject(MyData);
        System.out.println(parameters + " *** PRM");//this prints data
        JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.GET,
                "myurl",
                parameters, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                //TODO: handle success
                System.out.println(response+"***");

            }

        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
                //TODO: handle failure
            }
        });
        System.out.println("REQ "+jsonRequest+"");//not prints parms 
        Volley.newRequestQueue(ctx).add(jsonRequest);  

但是,当我运行app时

 [220] BasicNetwork.performRequest: Unexpected response code 500 for [my url]

我还尝试使用StringRequest和hashmap parms但问题相同

1 个答案:

答案 0 :(得分:0)

在发出截击请求时按照以下步骤

Volley Request Step By Step

  

从POST更改方法到GET。

相关问题