【发布时间】:2015-11-07 11:57:37
【问题描述】:
我正在尝试使用“Volley Library”将数据发布到 MVC WebApi。
您可以在此处找到 api 详细信息: http://mzrokz.somee.com/Help/Api/POST-api-LeadNowAppToCore-AddCustomer_firstname
如果成功,它将返回“1”。但是现在当我尝试发布它时会返回此异常
BasicNetwork.performRequest: Unexpected response code 404.
这是我到目前为止所尝试的。
RequestQueue queue = Volley.newRequestQueue(LeadNowAddUser.this);
StringRequest sr = new StringRequest(Request.Method.POST,"http://mzrokz.somee.com/api/LeadNowAppToCore/AddCustomer", new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.e("response",response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("firstName","ankur");
return params;
}
};
queue.add(sr);
请帮助我。提前致谢。
【问题讨论】:
-
您试图在不发送参数的情况下添加 custqomer?您做得不好,您必须在 gerParams() 中覆盖 getBody
-
@MaxPinto: 404 resp code is NOT FOUND, not BAD REQUEST :)
-
取决于服务器和api,但你是对的
标签: android http post android-volley