NET Web API接收POST方式的JSON格式

测试接口的工具:postman,发送参数为JSON格式,发送方式为POST

NET Web API接收POST方式的JSON格式_第1张图片

Web API接收的方法:

        public string PostSaveData()
        {
            LogHelper.WriteLog("接口请求:" + Request.RequestUri.ToString());
            HttpRequest request =  HttpContext.Current.Request;
            Stream postData = request.InputStream;
            StreamReader sRead = new StreamReader(postData);
            string postContent = sRead.ReadToEnd();
            sRead.Close();
            LogHelper.WriteLog("接收到的数据:" + postContent);
            return postContent;
        }

你可能感兴趣的:(Web,API)