带参数访问ApiController

 public string GetData(string methodName, string data)
        {
            try
            {
                //地址
                string url = "http://localhost:8080/api/AndroidEAGV/GetAGVScreenAndCarInfo?LoaclIP=192.168.1.100";
                //实例化
                WebClient client = new WebClient();
                //上传并接收数据
                Byte[] responseData = client.DownloadData(url);
                //接收返回的json的流数据,并转码
                return Encoding.UTF8.GetString(responseData);
            }
            catch (Exception ex)
            {
                return "400";               
            }
        }

 

posted @ 2021-12-21 09:49  蓝瑟黄昏  阅读(164)  评论(0编辑  收藏  举报