我将API的事务响应回调网址设置为:https://requestb.in/st4fz3st,并通过检查链接https://requestb.in/st4fz3st?inspect下面图片中显示的结果来调试响应过程,这给了我一个好的响应。
我想获取json数据,所以我写了这个c#代码
string GET(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
try
{
WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
return reader.ReadToEnd();
}
}
catch (WebException ex)
{
WebResponse errorResponse = ex.Response;
using (Stream responseStream = errorResponse.GetResponseStream())
{
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
String errorText = reader.ReadToEnd();
return errorText;
}
throw;
}
}
protected void Page_Load(object sender, EventArgs e)
{
x = GET(" https://requestb.in/st4fz3st");
Response.Write(x);
}
但我得到的是没有标记为红色的RAW BODY。
答案 0 :(得分:1)
你可以使用api。例如,在您的情况下:https://requestb.in/api/v1/bins/st4fz3st/requests
您可以使用Newtonsoft.Json解析结果。 'raw body'是body
property