Beam-Connectivity / grafana-dashboard-manager

Import and export Grafana dashboards for backup and dynamic provisioning
MIT License
59 stars 12 forks source link

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #13

Closed sagarnikam123 closed 11 months ago

sagarnikam123 commented 1 year ago

Grafana - 9.2.5 Python - 3.9.6

command to run:-

poetry run grafana-dashboard-manager \
--host "http://localhost:3000/" \
--username "admin" --password "admin123" \
download all \
--destination-dir "/Users/sagar/Documents/secura/work/grafanaDashboards/test1"

got error:-

INFO     Pulling all dashboards into /Users/sagar/Documents/secura/work/grafanaDashboards/test1...                                    dashboard_download.py:43
Traceback (most recent call last):
  File "/Users/sagar/Library/Python/3.9/bin/grafana-dashboard-manager", line 8, in <module>
    sys.exit(app())
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/typer/main.py", line 532, in wrapper
    return callback(**use_params)  # type: ignore
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/grafana_dashboard_manager/dashboard_download.py", line 46, in all
    folders = grafana.api.get("folders")
  File "/Users/sagar/Library/Python/3.9/lib/python/site-packages/grafana_dashboard_manager/api.py", line 64, in get
    return self._check_response(response.status_code, json.loads(response.text))
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
azend commented 1 year ago

I got this error when I provided a trailing slash to the --host argument. Try removing the trailing slash and see if that fixes it.

chan-vince commented 11 months ago

The CLI has now been updated to handle trailing slashes.