如果我设置版本,OData 元数据 url 请求失败
OData metadata url request fails if I set the version
以下代码获得 500:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/$metadata");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("DataServiceVersion", "4.0");
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
// this throws the 500
var response = request.GetResponse();
但这成功了:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/$metadata");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
var response = request.GetResponse();
这会引发错误:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/Airlines");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("DataServiceVersion", "4.0");
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
// this throws the 500
var response = request.GetResponse();
在请求元数据时有什么特殊的地方我不应该指定 DataServiceVersion 吗?
以下代码获得 500:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/$metadata");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("DataServiceVersion", "4.0");
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
// this throws the 500
var response = request.GetResponse();
但这成功了:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/$metadata");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
var response = request.GetResponse();
这会引发错误:
WebRequest request =
WebRequest.Create("https://services.odata.org/TripPinRESTierService/Airlines");
HttpWebRequest webRequest = request as HttpWebRequest;
webRequest.Accept = "application/atom+xml,application/xml";
request.Headers.Add("DataServiceVersion", "4.0");
request.Headers.Add("OData-MaxVersion", "4.0");
webRequest.AutomaticDecompression =
DecompressionMethods.Deflate | DecompressionMethods.GZip;
// this throws the 500
var response = request.GetResponse();
在请求元数据时有什么特殊的地方我不应该指定 DataServiceVersion 吗?