API returns "Update Your Browser" instead of PBF files, for some clients?

I’m trying to access the Mapillary API from inside Unity; I know my URLs are correct because they return exactly the files I want (vector tile PBFs) when I paste those URLs into Firefox’s address bar; however when I send the exact same URL as a UnityWebRequest, the response that I get is HTML, of a page that shows an “Update Your Browser” message.

Why would the API return data for some clients and not others? It even returns the PBF that I expect when I access the URL via powershell’s Invoke-WebRequest, so it clearly isn’t expecting a real “browser”; so far UnityWebRequest in particular is the only thing that I’ve found that gets the “Update Your Browser” webpage. Do I need to provide (or avoid) some specific User Agent string in order for it to work? Or is there actually some HTTP feature that Unity could be lacking? (This happens whether I’m requesting over HTTP or HTTPS, so it’s not an encryption thing…)

2 Likes

Hi!

Thanks for reporting, we should be able to fix it on our side when we check the User-Agent. In the mean time, try something like this:

var req = UnityWebRequest.Get("https://tiles.mapillary.com/maps/vtp/mly2/2/{z}/{x}/{y}?access_token=MLY|...");
req.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36");
req.SetRequestHeader("Accept", "application/x-protobuf, application/vnd.mapbox-vector-tile, */*");
yield return req.SendWebRequest();
// req.downloadHandler.data is now PBF
1 Like

That worked, thank you!

1 Like

Great!

Out of curiosity, if you don’t mind sharing, what are you building?

I’m trying to make something similar to “The Internet Road Trip”, but that runs inside VRChat.

2 Likes