远程API接口 返回数据如下:
{
"status": 0,
"code": 422,
"message": "该手机号已存在",
"extra": null
}
.NET HttpWebRequest 请求时 报错 远程服务器返回错误: (422) Unprocessable Entity
在浏览器直接GET请求 也可以返回正常,POSTMAN 请求也可以返回
远程API接口 返回数据如下:
{
"status": 0,
"code": 422,
"message": "该手机号已存在",
"extra": null
}
.NET HttpWebRequest 请求时 报错 远程服务器返回错误: (422) Unprocessable Entity
在浏览器直接GET请求 也可以返回正常,POSTMAN 请求也可以返回
在catch中进行处理 得到正常返回结果
try
{
...
}
catch (WebException ex)
{
HttpWebResponse res = (HttpWebResponse)ex.Response;
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
strMsg = sr.ReadToEnd();
}