Unknown Error, Error code 1, subcode 99

I have written a script to pull all images within a bbox- it gives me an unknown error, it being:

Error fetching Mapillary data: {"error":{"code":1,"message":"An unknown error occurred","error_subcode":99}}

I am using the requests module to handle the image requests.

This is the meat of my code:

url = f"https://graph.mapillary.com/images?access_token={MAPILLARY_ACCESS_TOKEN}&bbox={bbox}&fields=id,geometry"

print("Fetching image locations from Mapillary...")
response = requests.get(url)

if response.status_code == 200:
    data = response.json()
    print("Data received successfully.")

    image_coords = [(img["geometry"]["coordinates"][1], img["geometry"]["coordinates"][0]) for img in data["data"]]

    print(f"Total images found: {len(image_coords)}")

    print("Creating Folium map...")
    bologna_map = folium.Map(location=[44.4939, 11.3426], zoom_start=12)

    print("Adding markers to the map...")
    for lat, lon in image_coords:
        folium.Marker(location=[lat, lon], popup=f"Image at ({lat}, {lon})").add_to(bologna_map)

    print("Saving map as 'bologna_map.html'...")
    bologna_map.save("bologna_map.html")
    webbrowser.open("bologna_map.html")

else:
    print("Error fetching Mapillary data:", response.text)

There’s no documentation that I can find on Mapillary errors, hence the post.

I wonder if it’s timeout but shown as “unknown error”. Do you see any trace ID in the error response? If timeouts, just retry with backoff.

No, it’s not timeout because I have yet to make a singular successful request to Mapillary lol

I see. Can you reproduce the issue with curl and share me what’s in bbox={bbox}?

I’m happy to tell you I fixed it.
And I have no clue how :smiley:
:sob:
The thing is, before, I was using the redirect access token, then now I tried it with the Client Token (the permanent one for which you register) and now it worked! I didn’t change a singular line of code apart from that, so I can only assume it was that.
Thank you so much for staying here though, some emotional support was provided hahah

1 Like

@tao
It’s not working anymore. And I changed nothing, now I have actually zero clue what was causing the problem. I used dotenv to put my client token into an env file before pushing to github, and it broke
I have no clue what this is please help

At least it gives me a different error now-

Error fetching Mapillary data: {"error":{"message":"Invalid OAuth access token - Cannot parse access token","type":"OAuthException","code":190,"fbtrace_id":"AMrao4GF-xPnVPIyjwpEn4A"}}

If I don’t use .env however, and just have my client token in the file, it will execute just alright.
I have no clue why this is happening and yeah I can work with it, but I WOULD like not to push my client token to github. Though it should probably be fine.

It looks like the access_token=? passed in is invalid. Can you make sure it’s your app’s Client Token, i.e. MLY|xxx|yyy, or user’s access token?

To debug similar issues, I’d suggest print out the whole url first, and then use curl command to make the equivalent http request:

curl -v "https://graph.mapillary.com/images?access_token={MAPILLARY_ACCESS_TOKEN}&bbox={bbox}&fields=id,geometry"

and hopefully to find the root cause.

1 Like

It is my client’s access token. I will try to debug when I can, but my work with Mapillary seems to be mostly done :slight_smile:
Thank you so much for sticking by!

1 Like