Routing Service - Python - JSON


I was trying to use the Routing Service API via python. When I try to read the response with the following code, I receive an error “json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 10870 (char 10869)”.

json1_data = json.load(response.text)

From: 1.29520286174268,103.836921549212 (postal code: 238428)
To: 1.3034563846745,103.857453500579 (postal code: 198423)

I tried the same code and did not encounter this error with the rest of the coordinates. I am wondering if there is a step I missed to resolve this error. Hope someone can advise.

Thank you in advance!

Hi @infinititan,

Are you able to provide your code for that part so that we can troubleshoot at our end?

Do ensure that you have URIEncode for your API inputs and/or parameters.

Make sure your API endpoint is something like this:

For PT:,103.836921549212&end=1.3034563846745,103.857453500579&routeType=pt&date=2019-03-19&time=10%3A57%3A56&mode=BUS&maxWalkDistance=1000&numItineraries=3&token=xxx


Below is our code.

querystring = {"start": startCord, "end": endCord, "routeType": "pt", "token": tokendata["access_token"], "date": date, "time": time, "mode": mode, "maxWalkDistance": maxWalkDistance, "numItineraries": numItineraries}

    payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\nInfinitI1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
    headers = {
        'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
        'cache-control': "no-cache",
        'postman-token': "5f2cfd88-2933-944e-e382-a4bbd51cbe68"

    response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

    json1_data = json.loads(response.text)


I am not sure why you parsed it with your defined payload.

Have you test it on our Swagger for API endpoint first? and the Routing responses need to decode it with the polyline decoder as mentioned in our API Documentation,

Can you try to put your codes using online python compiler, such as using Then share with me the link via DM.

1 Like