0

I have an application which is calling an GET API for getting some reports. 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

Just for my curiosity I used a wrong username and password but still I am getting the same error 400 bad request

What is missing or wrong in my request?

smilu
  • 859
  • 7
  • 30
  • 53
  • http://stackoverflow.com/questions/692342/net-httpwebrequest-getresponse-raises-exception-when-http-status-code-400-ba – amit dayama Nov 05 '15 at 10:02
  • Possible to duplicate of http://stackoverflow.com/questions/23054960/getresponse-throws-400-bad-request – Kaushik Maheta Nov 05 '15 at 10:22
  • No, It doesn't help because the error stream shows me "something went wrong" – smilu Nov 05 '15 at 10:25
  • @KaushikMaheta they both are completely different. Before posting this question i had already gone through that post. – smilu Nov 05 '15 at 10:26

1 Answers1

0

There is something wrong with your request, your GET API require more information e.g header to process the request. You can find the general causes for the error from here http://www.checkupdown.com/status/E400.html

Adil Ansari
  • 346
  • 2
  • 13