1 (edited by tobi 2022-06-15 12:29:58)

Topic: Overpass API Calls return HTTP 400 status codes on android devices

I'm not sure if this is a bug or if i am doing something wrong here. So i rather post it in help.

I am using OnlineMapsOSMAPIQuery.Find() to make Overpass API calls which work absolutely fine in the editor, as well a some android devices. But on multiple devices i am getting the following Error Code via Android Logcat:

Can not load XML from string:
HTTP/1.1 400 Bad Request

Devices where it worked:
Motorola Moto g(8) power, Android 11
ZTE AXON7, Android 8

Devices that return HTTP Status code 400:
Samsung Galaxy A 50, Android 11
Samsung Galaxy M 30 S, Android 11
HUAWEI Device, Android 10

I am guessing it doesn't have anything to do with specific devices but rather with specific device settings. How ever Samsung Devices seems to have a 100% failure rate, so who knows smile

Re: Overpass API Calls return HTTP 400 status codes on android devices

Hello.

Please show your request URLs.
I'll check what's wrong.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

3 (edited by tobi 2022-06-15 15:27:29)

Re: Overpass API Calls return HTTP 400 status codes on android devices

I am using OnlineMapsOSMOverpassServer.main as set up in the OnlineMapsEditor component so the url would be

https://overpass-api.de/api/interpreter?data=

As for the request data, it looks like this

[maxsize:3000000];node(around:500,52.36112,13.35366)[amenity~"^(pharmacy|doctors|hospital|fire_station)$"];out count;

Its values vary of cours, but i get the HTTP Status Code no matter the different values.

Thanks for your help! smile

Re: Overpass API Calls return HTTP 400 status codes on android devices

I googled your problem and found two possible causes:
CORS and incorrect Content-Length of the request.
I don't know how CORS applies here, because it's related to cross-site communication, and usually comes up with WebGL.
But I've found it in several places, so maybe it's a bug in Unity and UnityWebRequest checks for it where it's not needed.

Try the following:
Try making a request to the Overpass API using WebClient or WebRequest. Most likely this will help.
If the problem persists, try using a different version of the editor. For example 2020.3 LTS or 2021.3 LTS.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

5 (edited by tobi 2022-06-16 16:08:28)

Re: Overpass API Calls return HTTP 400 status codes on android devices

Thank you for pointing me to WebClient, WebRequest. While I implemented HttpClient i figured out the problem wich is totally independent to the Request method itself.

The problem was the float variables of the position that are getting reformatted as they are put into the request string. The devices that didn't work are set to German, thus ToString() uses German CultureInfo wich means the decimal values are separated by commas not dots. So 50.555 will be formatted to 50,000. Which obviously leads to a bad request...