I have the following request. The API sends by default application/xml... i would like to change the header to this application/json to get JSON... how can i do that? it is not working now... Value ?xml of type java.lang.String cannot be converted to JSONObject
JsonObjectRequest jr = new JsonObjectRequest(Request.Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.i(TAG, response.toString());
parseJSON(response);
va.notifyDataSetChanged();
Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
pd.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG, error.getMessage());
}
}){
public String getBodyContentType()
{
return "application/json";
}};
mRequestQueue.add(jr);
}
No comments:
Post a Comment