如何正确地将请求发布到TOMTOM的trafficstats API?

时间:2019-02-10 21:49:26

标签: api tomtom

我正在尝试使TOMTOM trafficstats API正常工作,但未获得我期望的响应。我正在使用Postman生成对https://{{baseURL}}/traffic/trafficstats/routeanalysis/{{versionNumber}}?key={{apiKey}}

的POST请求

我已经设置了versionNumber = 1和key ='my TOMTOM access key'。该文档说baseURL应该是'api.tomtom.com',但是这样做时我收到“开发者未激活”的响应。但是,如果我使用baseURL ='move.tomtom.com',则会收到html响应。

我要发送以下邮件,以获取旧金山地区一条街道的历史交通数据:

{
    "jobName":"Test job",
    "distanceUnit":"MILES",
    "routes":[
        {
            "name":"The Embarcadero",
            "start":{
                "latitude":37.794672,
                "longitude":-122.393938
            },
            "via":[
                {
                    "latitude":37.783319,
                    "longitude":-122.388037
                    }
            ],
            "end":{
                "latitude":37.775170,
                "longitude":-122.395783
            },
            "fullTraversal":false,
            "zoneId":"UTC",
            "probeSource":"ALL"
        }
    ],
    "dateRanges":[
        {
            "name":"First day of November",
            "from":"2010-11-01",
            "to":"2010-11-01"
        }
    ],
    "timeSets":[
        {
            "name":"Monday morning hour",
            "timeGroups":[
                {
                    "times":[
                        "7:00-8:00"
                    ]
                }
            ]
        }
    ]
}

我的请求标头的“ Content-Type”设置为“ application / json”。

我收到以下html响应。我没有在html正文中看到预期的json数据。关于我做错了什么的任何想法?

 <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
        <title>TomTom Move</title>
        <base href="/" />
        <link rel="shortcut icon" href="/favicon.png">
        <link href="/css/styles.1337aa094afbb0bd778a.css" rel="stylesheet">
        <link rel="preload" href="/js/styles.7c8029e7a8f45b1dd768.js" as="script">
        <link rel="preload" href="/js/main.2d6a744cf686a687271d.js" as="script">
        <link rel="preload" href="/js/vendors~main.0c1946201ec04090e7a7.js" as="script">
        <link rel="prefetch" href="/js/styles.7c8029e7a8f45b1dd768.js">
        <link rel="prefetch" href="/js/main.2d6a744cf686a687271d.js">
        <link rel="prefetch" href="/js/vendors~main.0c1946201ec04090e7a7.js">
    </head>
    <body>
        <div id="app"></div>
        <!-- Tealium script -->
        <script type="text/javascript">
        (function (a, b, c, d) {
            a = '//tags.tiqcdn.com/utag/tomtom/move/prod/utag.js';
            b = document; c = 'script'; d = b.createElement(c); d.src = a; d.type = 'text/java' + c; d.async = true;
            a = b.getElementsByTagName(c)[0]; a.parentNode.insertBefore(d, a);
        })();
    </script>
        <script type="text/javascript" src="/js/styles.7c8029e7a8f45b1dd768.js"></script>
        <script type="text/javascript" src="/js/main.2d6a744cf686a687271d.js"></script>
        <script type="text/javascript" src="/js/vendors~main.0c1946201ec04090e7a7.js"></script>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

TrafficStats不是公共API。因此,如果您没有与TomTom达成协议,那么您将无法访问此API。对于此类问题,最好直接询问TomTom。

TomTom API的有效baseUrl是api.tomtom.com