404 HTML as responseText

This forum deals with any kind of trip optimization whether it is automatic planning or manual dispatching, refering to transport orders or service planning.
Post Reply
Elena
Posts: 1
Joined: Thu Nov 14, 2019 11:25 am

404 HTML as responseText

Post 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.
User avatar
Bernd Welter
Site Admin
Posts: 2546
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: 404 HTML as responseText

Post 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>
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at Youtube
I like the smell of PTV Developer in the morning... :twisted:
Post Reply