【发布时间】:2015-11-05 09:52:45
【问题描述】:
我有一个应用程序正在调用 GET API 来获取一些报告。 这是我的代码
HttpWebRequest myHttpWebRequest = null;
HttpWebResponse myHttpWebResponse = null;
myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("https://cybersource.com/DownloadReport/2015/11/04/profile/TransactionDetailReport.xml");
myHttpWebRequest.Method = "GET";
myHttpWebRequest.ContentType = "text/xml; encoding='utf-8'";
string authInfo = "username:password";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
myHttpWebRequest.Headers.Add("Authorization", "Basic " + authInfo);
myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
我浏览了很多文章并在这里和那里做了很多更改,但我仍然收到400 bad request
出于好奇,我使用了错误的用户名和密码,但我仍然收到同样的错误400 bad request
我的请求中缺少什么或错误?
【问题讨论】:
-
不,这没有帮助,因为错误流向我显示“出了点问题”
-
@KaushikMaheta 他们完全不同。在发布这个问题之前,我已经浏览了那个帖子。
标签: c# asp.net get httpwebrequest