سلام
دوستان چرا پارامتری POST با JsonObjectRequest ارسال نمیشه کد زیر
Map<String, String> params = new HashMap<String, String>();
params.put("name", "test");
JSONObject jsonObj = new JSONObject(params);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, URL, jsonObj, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(MainActivity.this,response.toString (),Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_LONG).show();
}
});
requestQueue.add(jsonObjectRequest);
کد سمت سرور هم اینه
header('Content-Type: application/json');
$_POST = json_decode(file_get_contents('php://input'), true);
$response = array();
$response['name'] = $_POST['ali'];
echo json_encode($response);
با StringRequest نوشتم بدون مشکل اجرا میشد و ارسال میکرد