简体   繁体   English

HttpWebRequest GET抛出400错误请求

[英]HttpWebRequest GET throwing 400 bad request

I have an application which is calling an GET API for getting some reports. 我有一个应用程序正在调用GET API以获取一些报告。 Here is my code 这是我的代码

 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();

I went through plenty of articles and did lot of changes here and there but still i am getting 400 bad request 我浏览了很多文章,并在各处进行了很多更改,但仍然收到400 bad request

Just for my curiosity I used a wrong username and password but still I am getting the same error 400 bad request 只是出于好奇,我使用了错误的用户名和密码,但仍然收到相同的错误400 bad request

What is missing or wrong in my request? 我的要求中有什么缺失或错误?

There is something wrong with your request, your GET API require more information eg header to process the request. 您的请求有问题,您的GET API需要更多信息,例如标头来处理请求。 You can find the general causes for the error from here http://www.checkupdown.com/status/E400.html 您可以从此处http://www.checkupdown.com/status/E400.html查找导致错误的一般原因

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

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