3liz / QuickOSM

QGIS plugin to fetch OSM data with the Overpass API
GNU General Public License v2.0
180 stars 54 forks source link

Nominatim API: Method Not Allowed #472

Closed kylepip closed 10 months ago

kylepip commented 10 months ago

What is the bug?

Attempting to download anything using QuickOSM is failing, with the Python error window showing a reply from the nominatim api: "server replied: Method Not Allowed". The QuickOSM log is pasted below, showing an attempt to download the Dallas city boundary. -->

2023-08-08T16:14:22     INFO    All OSM objects with keys ('admin_level'='8' and 'boundary'='administrative' and 'name'='Dallas') in Dallas are going to be downloaded.
2023-08-08T16:14:22     INFO    Query: admin_level_8_boundary_administrative_Dallas
2023-08-08T16:14:22     CRITICAL    Download failed: Error transferring https://nominatim.qgis.org/search?q=Dallas&format=json&info=QgisQuickOSMPlugin - server replied: Method Not Allowed
2023-08-08T16:17:59     CRITICAL    A critical error occurred, this is the traceback:
2023-08-08T16:17:59     CRITICAL    
2023-08-08T16:17:59     CRITICAL    base_processing_panel.py
2023-08-08T16:17:59     CRITICAL    [Errno 2] No such file or directory: '/private/var/folders/2b/y7wvjqc909zbz9db661wz8m40000gn/T/request-WuTsoU.json'
2023-08-08T16:17:59     CRITICAL     File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/ui/base_processing_panel.py", line 47, in run
              self._run()

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/ui/quick_query_panel.py", line 421, in _run
              num_layers = process_quick_query(

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/process.py", line 318, in process_quick_query
              return process_query(

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/process.py", line 251, in process_query
              final_query = query.prepare_query()

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/query_preparation.py", line 314, in prepare_query
              self._replace_geocode_area()

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/query_preparation.py", line 283, in _replace_geocode_area
              self._query_prepared = re.sub(template, lambda m: replace(

              File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/re.py", line 210, in sub
              return _compile(pattern, flags).sub(repl, string, count)

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/query_preparation.py", line 283, in 
              self._query_prepared = re.sub(template, lambda m: replace(

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/query_preparation.py", line 263, in replace
              osm_id = self._nominatim.get_first_polygon_from_query(search)

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/api/nominatim.py", line 97, in get_first_polygon_from_query
              data = self.query(query)

              File "/Users/kylepip/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/QuickOSM/core/api/nominatim.py", line 70, in query
              with open(self.result_path, encoding='utf8') as json_file:

Environment

varbela commented 10 months ago

I have a similar API error. I tested on 2 systems. The error occurs when trying to Run a query with the plugin.

Environment 1.

Environment 2.

An error has occurred while executing Python code: 

QuickOSM.core.exceptions.NetWorkErrorException: Nominatim API : Download failed: Error transferring https://nominatim.qgis.org/search?q=Veszprém&format=json&info=QgisQuickOSMPlugin - server replied: Method Not Allowed 
Traceback (most recent call last):
  File "C:\Users/zed90/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QuickOSM\core\api\nominatim.py", line 48, in error
    raise NetWorkErrorException('Nominatim API', ', '.join(messages))
QuickOSM.core.exceptions.NetWorkErrorException: Nominatim API : Download failed: Error transferring https://nominatim.qgis.org/search?q=Veszprém&format=json&info=QgisQuickOSMPlugin - server replied: Method Not Allowed

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
QGIS version: 3.32.1-Lima Lima, 4a078ecf63 

Python Path:
C:/PROGRA~1/QGIS33~1.1/apps/qgis/./python
C:/Users/zed90/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/zed90/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS33~1.1/apps/qgis/./python/plugins
C:\PROGRA~1\QGIS33~1.1\apps\grass\grass83\etc\python
C:\Users\zed90\Documents
C:\Program Files\QGIS 3.32.1\bin\python39.zip
C:\PROGRA~1\QGIS33~1.1\apps\Python39\DLLs
C:\PROGRA~1\QGIS33~1.1\apps\Python39\lib
C:\Program Files\QGIS 3.32.1\bin
C:\PROGRA~1\QGIS33~1.1\apps\Python39
C:\PROGRA~1\QGIS33~1.1\apps\Python39\lib\site-packages
C:\PROGRA~1\QGIS33~1.1\apps\Python39\lib\site-packages\win32
C:\PROGRA~1\QGIS33~1.1\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS33~1.1\apps\Python39\lib\site-packages\Pythonwin
C:/Users/zed90/AppData/Roaming/QGIS/QGIS3\profiles\default/python
Gustry commented 10 months ago

I can confirm the issue.

It seems the Nominatim server has been updated by rejecting POST requests.

➜ curl -X POST 'https://nominatim.qgis.org/search?q=montpellier&format=json&info=QgisQuickOSMPlugin'
{"title": "405 Method Not Allowed"}
➜ curl -X GET 'https://nominatim.qgis.org/search?q=montpellier&format=json&info=QgisQuickOSMPlugin'
[{"place_id":361351658,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":28722,"lat":"43.6112422","lon":"3.8767337","class":"boundary","type":"administrative","place_rank":16,"importance":0.6412041870185823,"addresstype":"city","name":"Montpellier","display_name":"Montpellier, Hérault, Occitanie, France métropolitaine, France","boundingbox":["43.5667083","43.6533580","3.8070597","3.9413208"]},{"place_id":298587617,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":7362050,"lat":"45.855586","lon":"-75.163651","class":"boundary","type":"administrative","place_rank":16,"importance":0.3738687964459321,"addresstype":"village","name":"Montpellier","display_name":"Montpellier, Papineau, Outaouais, Québec, Canada","boundingbox":["45.8140214","45.9735738","-75.3946681","-75.1189169"]},{"place_id":361351046,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"relation","osm_id":1686656,"lat":"43.5577224","lon":"3.8753793538384635","class":"boundary","type":"administrative","place_rank":14,"importance":0.3380411950818732,"addresstype":"municipality","name":"Montpellier","display_name":"Montpellier, Hérault, Occitanie, France métropolitaine, France","boundingbox":["43.3023828","43.8129840","3.4928290","4.1946047"]}]

Like on osm.org, the plugin was doing a request, with the searched area in the URL as a query string, but using POST instead of GET (on osm.org)

Gustry commented 10 months ago

OSM nominatim servers are now rejecting POST requests.

I will update the plugin

pathmapper commented 10 months ago

Thanks for the fast response @Gustry, confirmed this fixes the issue.

Gustry commented 10 months ago

Thanks for the feedback. It was going to be quite a major issue for a lot of users :)