将数据发布到 MVC Web 时 Volley 库不工作 Api

Volley library not working while posting the data to MVC Web Api

我正在尝试 POST 使用 "Volley Library" 向 MVC WebApi 发送数据。

您可以在此处找到 api 详细信息: http://mzrokz.somee.com/Help/Api/POST-api-LeadNowAppToCore-AddCustomer_firstname

如果成功,它将return“1”。但是现在当我试图 post 它 return 这个异常

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);

请帮帮我。提前致谢。

我在 chrome 浏览器的 Advanced Rest 客户端扩展程序中尝试 post 数据,但出现 404 错误。 请检查您的网络服务

http://i.imgur.com/z70z4km.png

根据您 link 中的文档,这是没有正文参数的 POST 请求。它使用URL参数,所以你只需要更新你的应用程序中的URL并删除getParams,请看下面的截图(我使用Postman)。希望这对您有所帮助!