我目前正在尝试将JsonObject发布到我的API并从服务器获取JsonArray响应。我该怎么办?如果我尝试
,我会收到异常错误JsonObjectRequest postRequest = new JsonObjectRequest(Request.Method.POST, url_test,new JSONObject(params),
new Response.Listener<JSONObject>() {
@Override
答案 0 :(得分:0)
试试这些..
url = "http://your Api post";
StringRequest postRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
// response
Log.d("Response", response);
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
// error
Log.d("Error.Response", response);
}
}
) {
//You send the key and value to server you enter here
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("key", "value");
return params;
}
};
queue.add(postRequest);