I work with android volley library! I have some don't understand problem with sending request with json and DELETE method from server. Request successfully connect to server but sended parameters server will receive is empty. But header request work normaly! Please help me!
public void deletePoint(String id) throws JSONException {
dialog.show();
queue = Volley.newRequestQueue(getActivity(), new ExtHttpClientStack(new SslHttpClient().getHttpClient()));
String urlRequest = getUrl();
JSONObject param = new JSONObject();
param.put("id", id);
JsonObjectRequest userRequest = new JsonObjectRequest(Request.Method.DELETE,
urlRequest,
param,
deletePointRequestSuccessListener(),
reqErrorListener()){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = super.getHeaders();
if (headers == null || headers.equals(Collections.emptyMap())) {
headers = new HashMap<String, String>();
}
if (ProgressFragment.this.headers != null) {
headers.keySet().removeAll(ProgressFragment.this.headers.keySet());
headers.putAll(ProgressFragment.this.headers);
}
headers.put("Content-Type", "application/json");
return headers;
}
};
userRequest.setRetryPolicy(new DefaultRetryPolicy(
MY_SOCKET_TIMEOUT_MS,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
dialog.show();
queue.add(userRequest);
}
private Response.Listener<JSONObject> deletePointRequestSuccessListener() {
return new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
dialog.hide();
Gson gson = new Gson();
Success resp = gson.fromJson(response.toString(), Success.class);
if(resp.isSuccess()){
Toast.makeText(getActivity(), getString(R.string.success), Toast.LENGTH_SHORT).show();
try {
getGraphData();
} catch (JSONException e) {
e.printStackTrace();
}
}
dialog.hide();
}
};
}