mvexel / overpass-api-python-wrapper

Python bindings for the OpenStreetMap Overpass API
Apache License 2.0
368 stars 90 forks source link

Returned XML is parsed as JSON #96

Open rivermont opened 6 years ago

rivermont commented 6 years ago

Seems to happen at api.py#87.

import overpass

api = overpass.API(debug=True, timeout=250)
query = "<query>"
response = api.get(query, responseformat="xml", verbosity="meta")
print(response)
Traceback (most recent call last):
  File "overpass_script.py", line 4, in <module>
    response = api.get(query, responseformat="xml", verbosity="meta")
  File "/usr/local/lib/python3.5/dist-packages/overpass/api.py", line 80, in get
    response = json.loads(r.text)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column
mvexel commented 6 years ago

With a very simple query, it works using Python 3. Can you add the exact query and Python version you are using?

mvexel commented 6 years ago

Closing because no more feedback for some time. Feel free to re-open @rivermont if you are having the same problem still.

mvexel commented 6 years ago

Wait a minute.. There is something specific to string encoding here.. It would really help to get the specific query that gave you this problem @rivermont -- thanks!