Code Monkey home page Code Monkey logo

Comments (6)

m0nhawk avatar m0nhawk commented on July 20, 2024

All the methods in the library is expecting JSON (dictionaries in Python) values as an input.

So, something like this will work:

with open("test.json") as json_data:
    test = json_data.read()
    test = json.loads(test)

print(api.dashboard.update_dashboard(test))

Feel free to re-open this issue or create a new one for other questions.

from grafana_api.

ljades avatar ljades commented on July 20, 2024

Hey, so I just started using the API and I'm running to the same issue now, except I am using a Python dict to represent the dashboard, but I'm still getting the same error.

I even tried with one of the test case dicts in test_dashboard.py to be sure it wasn't a malformed json, and that didn't work either.

from grafana_api.

ljades avatar ljades commented on July 20, 2024

@m0nhawk for context:

my_db = {'id': None, 'uid': None, 'title': 'hithere', 'tags': ['templated'], 'timezone': 'browser', 'schemaVersion': 16, 'version': 0}

grafana_api = GrafanaFace(auth='...', host='...')

# get operations work fine. I tested folders.get_all_folders(), for example, both with improper auth and proper auth to make sure it was working as expected.

grafana_api.dashboard.update_dashboard({'dashboard': my_db, 'folderId': 0, 'overwrite': True})

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../site-packages/grafana_api/api/dashboard.py", line 26, in update_dashboard
    r = self.api.POST(put_dashboard_path, json=dashboard)
  File ".../site-packages/grafana_api/grafana_api.py", line 136, in __request_runnner
    return r.json()
  File ".../site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File ".../python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File ".../python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File ".../python3.7/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)

from grafana_api.

ljades avatar ljades commented on July 20, 2024

Grafana version v6.6.1

from grafana_api.

ljades avatar ljades commented on July 20, 2024

It looks like the exception is happening on the response being converted to json.

from grafana_api.

ljades avatar ljades commented on July 20, 2024

Never mind, after debugging I found out the url was automatically resolving to the wrong protocol. Setting it fixed the whole thing!

from grafana_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.