簡體   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