我有以下url在浏览器中返回JSON但在使用httpwebrequest时返回空。我需要得到json
https://www.dell.com/support/orders/us/en/04/order/GetMultipleOrderList?Period=180&PageSize=1000&PageNumber=1&SortBy=Date&SortDirection=DESC&SearchType=PoNumber&SearchValue=PO0008362&ActionItem=Select&VerifyType=PostalCode&VerifyValue=30082
我的代码是
PONumber = "PO0008362";
ZipCode = "30082";
String URL = String.Format("https://www.dell.com/support/orders/us/en/19/order/GetMultipleOrderList?Period=180&PageSize=1000&PageNumber=1&SortBy=Date&SortDirection=DESC&SearchType=PoNumber&SearchValue={0}&ActionItem=Select&VerifyType=PostalCode&VerifyValue={1}", PONumber, ZipCode);
HttpWebRequest Request = WebRequest.Create(URL) as HttpWebRequest;
Request.Method = "GET";
Request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
Request.Headers.Add("Accept-Language: en-US,en;q=0.5");
Request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; InfoPath.2; .NET4.0C; .NET4.0E)";
Request.UserAgent = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0";
Request.CookieContainer = new CookieContainer();
HttpWebResponse Response = Request.GetResponse() as HttpWebResponse;
StreamReader sr = new StreamReader(Response.GetResponseStream());
StringBuilder HTMLResponse = new StringBuilder("");
HTMLResponse.Append(sr.ReadToEnd());
sr.Close();
return HTMLResponse;
使用上面的代码我总是得到一个空结果而不是json,但是当我在浏览器中使用相同的URL时,我收到了json。