I try to use GET on Volley , but i need send request to application/json
.
I take a look for some answers , i try to use jsonBody
, but it
I try to use GET on Volley
The docs for the method you are calling says this
Constructor which defaults to GET if jsonRequest is null, POST otherwise
You can't GET with an HTTP JSON body. Maybe that's the error.
//I try to use this for send Header is application/json jsonBody = new JSONObject("{\"type\":\"example\"}");
That's not the header, so pass in null here to do GET
new JsonObjectRequest(url, null,
And towards the end of your request, override a method to request JSON
...
@Override
public void onErrorResponse(VolleyError error) {
Log.e("TAG", error.getMessage(), error);
}
}) { // Notice no semi-colon here
@Override
public Map getHeaders() throws AuthFailureError {
Map params = new HashMap();
params.put("Content-Type", "application/json");
return params;
}
};