httpresponse 的响应变化
我正在为一家公司开发一个网上商店,该公司有一个名为 simPRO 的在线业务管理软件。所以我必须使用我提供的 API 从 simPRO 检索。它基于 xml,命令必须使用 httpget 或 post 发送。
我使用以下代码来获取产品的数据
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
//byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(uri);
req.Method = "GET";
using (WebResponse res = req.GetResponse())
{
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
try
{
resultBox.Text = backstr;
}
catch (NullReferenceException ex)
{
resultBox.Text = ex.ToString();
}
sr.Close();
res.Close();
}
在 uri 中,我根据 API 传递了一个 xml 脚本。
我收到的回复不是我所期望的。
meta HTTP-EQUIV="refresh" content=0;url="index.php"
我只是很困惑上面的代码有问题吗?或者是我传递的 xmlscript?
I am developing an online shop for a firm which have an online business management software called simPRO. so i have to retrieve from simPRO using an API which i am provided with. Its xml based and the commands have to be send using httpget or post.
i used this following code to get the data of products
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
//byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(uri);
req.Method = "GET";
using (WebResponse res = req.GetResponse())
{
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
try
{
resultBox.Text = backstr;
}
catch (NullReferenceException ex)
{
resultBox.Text = ex.ToString();
}
sr.Close();
res.Close();
}
in the uri i have passed an xml script according to the API.
i am getting this response which is not what i expected.
meta HTTP-EQUIV="refresh" content=0;url="index.php"
i am just confused that is there something wrong in the code above? or is it the xmlscript which i am passing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论