I have created JSONRequest by using volley, It successfully hits the service, I checked the service end, It receives the data, and send "Success" in return.
The problem is that, Service returns String
in output, and Volley excepts some JSON Data
in output. So it executes the onError
Method, instead of onResponse
.
Kindly guide me how to make it accept string response, or is it not possible when you are using JSONObject
as request.
Request<JSONObject> jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, "http://192.168.0.101:8888/api/services/mytest",
jsonParent, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("Success", response.toString());
deleteFile();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Error", error.toString());
deleteFile();
}
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(jsonObjectRequest);