Page 1 of 1

404 HTML as responseText

Posted: Thu Nov 14, 2019 2:32 pm
by Elena
I want to make a request for a tour, but I get in the answer under the item responseText no JSON but an HTML page with the error code 404 and my page remain blank.

Re: 404 HTML as responseText

Posted: Thu Nov 21, 2019 6:08 pm
by Bernd Welter
Hello Elena,

here's a functional complete minimal example of how to perform a routing request. Save it as stand alone HTML file and add your token in line 11. You can see the response of the call in your browsers developer tools.

Does this match your requirement?

Bernd

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <title>Xroute Demo</title>
        <script src="https://xserver2-europe-test.cloud.ptvgroup.com/services/xroute-client.js"></script>
    </head>
    <body>
        <div id="map">
        </div>
        <script>
            let token = '<your token>';
            let xroute = new XRouteClient();
            xroute.setCredentials('xtok', token);
            let A = {
                "$type": "OffRoadWaypoint",
                "location": {
                    "offRoadCoordinate": {
                        "x": 6.1256572,
                        "y": 49.5983745
                    }
                }
            };

            let B = {
                "$type": "OnRoadWaypoint",
                "location": {
                    "coordinate": {
                        "x": 6.1256572,
                        "y": 49.4816576
                    }
                }
            };

            xroute.calculateRoute({
                "waypoints": [A, B],
                "storedProfile": "car",
                "resultFields": {
                    "eventTypes": [
                    "MANEUVER_EVENT"
                    ],
                    "guidedNavigationRoute": true,
                    "polyline": true
                },
                
            }, routingCompleted);

            function routingCompleted(route, exception) {
                console.log(route.distance + 'm in ' + route.travelTime + 's');
                console.log(route);
            }
        </script>
    </body>
</html>