首页 > 解决方案 > Bing 地图:时区 REST API 不起作用

问题描述

我尝试使用 Time Zone REST API,无论我使用什么参数和检查什么坐标,它都不会返回预期的数据,并且在所有情况下我都会得到以下结果:

请求: https ://dev.virtualearth.net/REST/v1/TimeZone/point=40.7844503,-73.528732?datetime=2021-04-23T00:00:00Z&includeDstRules=true&key=API_KEY

回复:

{
   "authenticationResultCode":"ValidCredentials",
   "brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
   "copyright":"Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
   "resourceSets":[
      {
         "estimatedTotal":1,
         "resources":[
            {
               "__type":"RESTTimeZone:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
               "timeZoneAtLocation":[
                  
               ]
            }
         ]
      }
   ],
   "statusCode":200,
   "statusDescription":"OK",
   "traceId":"55590586fc5b4183865c58af24845970|DU00000D6E|0.0.0.1|Ref A: 3D98A80E080A45289BEC315D7EE37BDA Ref B: DB3EDGE1522 Ref C: 2021-04-23T14:04:29Z"
}

这不是事务使用限制问题,我最近才注册了该服务。我尝试使用其他 REST API 服务(例如 Elevations API),它确实有效。

请开导我的眼睛并向我解释什么是错的。

标签: timezonebing-mapsrest

解决方案


看起来您的请求网址是错误的,只需从您的查询中删除“point =”即可。 https://dev.virtualearth.net/REST/v1/TimeZone/40.7844503,-73.528732?datetime=2021-04-23T00:00:00Z&includeDstRules=true&key=API_KEY

{
  "authenticationResultCode": "ValidCredentials",
  "brandLogoUri": "http://dev.virtualearth.net/Branding/logo_powered_by.png",
  "copyright": "Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
  "resourceSets": [
    {
      "estimatedTotal": 1,
      "resources": [
        {
          "__type": "RESTTimeZone:http://schemas.microsoft.com/search/local/ws/rest/v1",
          "timeZone": {
            "genericName": "Eastern Standard Time",
            "abbreviation": "EST",
            "ianaTimeZoneId": "America/New_York",
            "windowsTimeZoneId": "Eastern Standard Time",
            "utcOffset": "-5:00",
            "convertedTime": {
              "localTime": "2021-04-22T20:00:00",
              "utcOffsetWithDst": "-4:00",
              "timeZoneDisplayName": "Eastern Daylight Time",
              "timeZoneDisplayAbbr": "EDT"
            },
            "dstRule": {
              "dstStartMonth": "Mar",
              "dstStartDateRule": "Sun>=8",
              "dstStartTime": "2:00",
              "dstAdjust1": "1:00",
              "dstEndMonth": "Nov",
              "dstEndDateRule": "Sun>=1",
              "dstEndTime": "2:00",
              "dstAdjust2": "0"
            }
          }
        }
      ]
    }
  ],
  "statusCode": 200,
  "statusDescription": "OK",
  "traceId": "2fd8f869974046f182ac948253e83de9|HK00000C07|0.0.0.1"
}

您可以在https://docs.microsoft.com/en-us/bingmaps/rest-services/timezone/find-time-zone中找到更多详细信息和示例


推荐阅读