I have this api request code in retrofit i want to send the request using volley Everything is all right but i don't know what is the purpose of hasbody = true. And when i send request using volley it can't works. Kindly guide me how can i send request on this api using volley.
@HTTP(method = "DELETE", path = "ad/delete/", hasBody = true)
Call<ResponseBody> deleteMyAds(
@Body JsonObject jsonObject,
@HeaderMap Map<String, String> headers
);
This is my volley function:
private void deleteFromMyAdds(){
final ProgressDialog progress = new ProgressDialog(mCntxt);
progress.setTitle(mCntxt.getResources().getString(R.string.loading_t));
progress.setMessage(mCntxt.getResources().getString(R.string.loading_t));
progress.setCancelable(false); // disable dismiss by tapping outside of the dialog
progress.show();
RequestQueue queue = Volley.newRequestQueue(mCntxt);
Map<String, String> params22 = new HashMap<String, String>();
params22.put("ad_id", Utils.ad_home_clicked);
JSONObject jsonObject = new JSONObject(params22);
JsonObjectRequest jsonRequest = new JsonObjectRequest(Request.Method.DELETE, Utils.base_Url+"ad/delete/", jsonObject,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("ResponseAdds :" , response.toString());
progress.dismiss();
MyPalmTreeFragment carsFragment = new MyPalmTreeFragment();
AppCompatActivity activity = (AppCompatActivity) mCntxt;
activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainer,
carsFragment).addToBackStack(null).commit();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progress.dismiss();
Toast.makeText(mCntxt,mCntxt.getResources().getString(R.string.somethingwentwrong_t), Toast.LENGTH_SHORT).show();
error.printStackTrace();
}
}) {
@Override
public Map<String, String> getHeaders() {
Map<String, String> params = new HashMap<String, String>();
params.put("Accept", "application/json");
params.put("Authorization", Utils.user_token);
params.put("Purchase-Code", "b638a7e5-d833-417e-b79c-c28050720738");
params.put("custom-security", "11223344");
params.put("Adforest-Lang-Locale", "en");
params.put("Adforest-Request-From", "android");
params.put("Content-Type", "application/json");
params.put("Cache-Control", "max-age=640000");
return params;
}
};
queue.add(jsonRequest);
}