i need help to fix this bug, i already use a delete method in volley but when i tried,
the code showing response 400, here is my code
JSONObject params = new JSONObject();
try {
String id = getIntent().getStringExtra(KEY_NIK);
params.put("id", id);
}
catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest request=new JsonObjectRequest(Request.Method.DELETE, "http://******/index", params, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
hideDialog();
Toast.makeText(getApplicationContext(), "sudah di update", Toast.LENGTH_LONG).show();
detail_activity.this.finish();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "maaf ada kesalahan", Toast.LENGTH_LONG).show();
}
})
{
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
String creds = String.format("%s:%s", "admin", "Databa53");
String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.DEFAULT);
headers.put("Authorization", auth);
return getHeaders();
}
};
RequestQueue requestQueue = Volley.newRequestQueue(detail_activity.this);
requestQueue.add(request);
What I have tried:
i tried using postman but in worked but when i using android, it doesn't work