【发布时间】:2019-06-01 13:23:36
【问题描述】:
我使用 Mac 的伙伴可以毫无问题地运行该程序,但是当我尝试运行它时,它会出现问题
WebException:远程服务器返回错误:(400) Bad Request。
我尝试复制请求 URL(在构建字符串之后)并且浏览器给了我预期的答案。
代码是这样的:
double SearchLatitude = 41.480687;
double SearchLongitude = -8.527346;
double Radius = 10; // km
int maxResults = 5;
string bingMapsKey = "MyKey";
string requestUrl = string.Format("http://spatial.virtualearth.net/REST/v1/data/c2ae584bbccc4916a0acf75d1e6947b4/NavteqEU/NavteqPOIs" +
"?spatialFilter=nearby({0},{1},{2})&$filter=EntityTypeID Eq 5400&$top={3}&key={4}", SearchLatitude, SearchLongitude, Radius, maxResults,bingMapsKey);
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
这可能是 Windows 问题吗?
【问题讨论】:
-
如果那是你真正的 bingMapsKey 那么你就不应该发布它。
-
@HenkHolterman 不,不是
-
@HenkHolterman 它已修改,但我可以将其更改为看起来不真实
标签: c# .net-core httprequest