繁体   English   中英

HttpWebRequest GET抛出400错误请求

[英]HttpWebRequest GET throwing 400 bad request

我有一个应用程序正在调用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

我的要求中有什么缺失或错误?

您的请求有问题,您的GET API需要更多信息,例如标头来处理请求。 您可以从此处http://www.checkupdown.com/status/E400.html查找导致错误的一般原因

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM