0

There seems to be an overwhelming amount of confusion to using Volley to do this. I have seen 20+ questions asking how to do this, but still I don't know why what I am doing is getting an empty response.

{"results":[]}

Here is the code I use to setup the JSONObjectRequest

    String url = "http://bsg.redmatmediabizapp.com/admin/push/getPushNotifications.php";
    JSONObject params = new JSONObject();
    try {
        params.put("AppVersion", "BSG");
        params.put("userID", "2");
    } catch (JSONException e) {
        // TODO handle error
        e.printStackTrace();
    }


    JsonObjectRequest request = new JsonObjectRequest(
            Request.Method.POST, url, params,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    populateNavigationDrawer(response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //TODO Handle Error
                    Log.d(TAG, error.getMessage());
                }
            });

    singleton.addToRequestQueue(request);

If I pass the same url and parameter key:value pairs to http://hurl.it I get a longer response, so I know the server is responding correctly.

izzy
  • 1,309
  • 1
  • 15
  • 25
  • 1
    I think you have the same problem: http://stackoverflow.com/a/19945676/1032167 – varren Feb 09 '16 at 04:04
  • excellent! I guess I should start searching for answers that are voted up the most. – izzy Feb 09 '16 at 04:53
  • Funny thing is I think I based the code for this question off another answer to that question, but didn't work ... :( but YES the answer make as correct to that question worked for me here, maybe mark this as duplicate – izzy Feb 09 '16 at 04:58

0 Answers0