JorgeParada
JorgeParada

Reputation: 603

Volley Send POST Params Always Empty

I have this code on my Android client:

    int method = Request.Method.POST;

    JSONObject params = new JSONObject();
    try {
        params.put("data", userJson);
    } catch (JSONException e) {
        LogSystem.e(tag, "JsonObject - Params", e);
    }

    String url = "http://appdorneira.com:8001/rest/test";
    // URL_USER_INFO;// + "?data='" + userJson + "'";
    LogSystem.d(tag, url);

    JsonObjectRequest request = new JsonObjectRequest(method, url, params,
            resOk, errorListener);
    queue.add(request);

But in my Server always have something like:

GET:QueryDict: {}, POST:QueryDict: {}

I don´t see the error. What i do wrong?

Upvotes: 2

Views: 1250

Answers (2)

JorgeParada
JorgeParada

Reputation: 603

Now, I´m using VolleyPlus (https://github.com/DWorkS/VolleyPlus) and this Code Works For Me:

    int method = Request.Method.POST;

    String url = URL_USER_INFO;
    LogSystem.d(tag, url);

    StringRequest request = new StringRequest(method, url, resOk,
            errorListener) {

        protected Map<String, String> getParams()
                throws com.android.volley.error.AuthFailureError {
            Map<String, String> params = new HashMap<String, String>();
            params.put("data", userJson);
            return params;
        };
    };

    queue.add(request);

Upvotes: 2

maxxxo
maxxxo

Reputation: 754

Debug and trace the connection to see what was really sent. Problem might be on server also.

Upvotes: 1

Related Questions