AnsweredAssumed Answered

Getting Invalid Session ID In response of Rest Using Java (Android)

Question asked by Rishu Gupta on Aug 29, 2016

Hi Folks

 

Im developing an application in java and im trying to fetch records using REST .. But Getting Below Problems

 

 

 

private void getUserDetails(final String session){
    pDialog = new ProgressDialog(LoginActivity.this);
    pDialog.setMessage("Please wait...");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.show();

    //Creating a string request
    StringRequest stringRequest = new StringRequest(Request.Method.POST, URL,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.e("SugarCRM"," UserDetails resp = "+ response);

                    pDialog.dismiss();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //You can handle error here if you want
                    pDialog.dismiss();
                }
            }){
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {

            Map<String,String> requestMap = new HashMap<>();
            requestMap.put("method", "get_entry_list");
            requestMap.put("input_type", "JSON");
            requestMap.put("response_type", "JSON");

            String[] fieldlist={"id","first_name","last_name","picture"};
            String[] link_name_to_fields_array={};

            Map<String, Object> rest_data = new HashMap<String, Object>();
            rest_data.put("session", session_id);
            rest_data.put("module_name", "Users");
            rest_data.put("query", "");
            rest_data.put("order_by", "last_name");
            rest_data.put("offset", 0);
            rest_data.put("select_fields", "");
            rest_data.put("link_name_to_fields_array", "");
            rest_data.put("max_results", 20);

            Gson gson = new Gson();
            requestMap.put("rest_data", gson.toJson(rest_data));

            Log.e("SugarCRM"," data sending =  "+gson.toJson(rest_data));


            //returning parameter
            return requestMap;
        }
    };

    //Adding the string request to the queue
    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}

Outcomes