Volley, Custom Header

0

Currently I have a problem I find the following code to make a POST call

 public void pendingPaymentsCollections(final Context context, String request, final Response.Listener<GetPendingPaymentsCollections> listener, final Response.ErrorListener errorListener) {
    int method = Request.Method.POST;
    String serviceURL = URLLocal;
    String req = "";
    try {
        req = request;
        RequestQueue queue = Volley.newRequestQueue(context, null);
        objectRequest = new ObjetRequest(method, serviceURL, GetPendingPaymentsCollections.class, req, listener, errorListener)
       /* {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String>  params = new HashMap<String, String>();
                params.put("sessionToken", Globals.getSessionToken());
                params.put("Content-Type", "application/json; charset=utf-8");

                return params;
            }
        }*/;
        objectRequest.setRetryPolicy(new DefaultRetryPolicy(TIME_OUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        queue.add(objectRequest);
    } catch (Exception e) {
        Logger logger = Logger.getAnonymousLogger();
        logger.log(Level.SEVERE, "an exception was thrown", e);
    }
}

If I try to perform the

{
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String>  params = new HashMap<String, String>();
            params.put("sessionToken", Globals.getSessionToken());
            params.put("Content-Type", "application/json; charset=utf-8");

            return params;
        }
    }

the service fails me, but it does not send me any error message in the LOG, so the service is mapped against my classes without problem and it works 100%, but when putting the header like this, the service always goes with the ERROR

    
asked by Bruno Sosa Fast Tag 29.12.2017 в 17:57
source

0 answers