geoserver-rest
geoserver-rest copied to clipboard
get_status() doesn't return json
Hey! Thanks for a great product!
Description
geoserver-rest==2.3.4
requests==2.28.1
Geoserver API doesn't return a JSON-response to a request in the get_status()
method of the Geoserver class. So return of the method doesn't produce a valid output. I'm not sure if it is only my specific problem because the get_system_status()
method works just fine with a similar request.
Code to reproduce
from geo.Geoserver import Geoserver
geo = Geoserver('http://127.0.0.1:9090', username='admin', password='geoserver')
status = geo.get_status()
system_status = geo.get_system_status()
print(status)
print(system_status)
Output (truncated)
('get_status error: ', JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
{'metrics': {'metric': [{'available': False, 'description': 'Operating system', 'name': 'OPERATING_SYSTEM', 'unit': '', 'category': 'SYSTEM', 'identifier': 'OPERATING_SYSTEM', 'priority': 1, 'value': 'NOT AVAILABLE'}, ...
Possible solution
Add a header to ensure json return.
def get_status(self):
"""
Returns the status of the geoserver. It shows the status details of all installed and configured modules.
"""
try:
url = "{}/rest/about/status.json".format(self.service_url)
r = requests.get(url, auth=(self.username, self.password), headers={"Accept": "application/json"})
return r.json()