Comments (3)
FYI: I've been testing different servers.
It works on my personal grafana instance but not on the one we use at work.
So far, after setting server settings to the exact same values, this does not work on my work instance.
The only difference so far is that the one on my work is using version "Grafana v7.1.3 (5723d951af)"
Deleting a datasource also seems to work... which is also a post request... I'm out of options here
from grafana_api.
It should either output the 200 response with:
{"message":"Active organization changed"}
Or some other message, I was not able to reproduce it with multiple Grafana versions.
From the error, it's successfully switches the organization (or at least returning status code less than 400) and returns non-JSON response:
File "/home/yentel/.local/lib/python3.7/site-packages/grafana_api/grafana_api.py", line 136, in __request_runnner
return r.json()
I'd recommend to test cURL to see what's going on (see below), unfortunately, right now the library doesn't have nice debug capabilities (though, I have this in mind).
As for cURL, you can run the following command and see what's going on:
curl -X POST -u myusername:mypassword http://somesite.com:port/api/user/using/15
from grafana_api.
Sorry for the late reply, some other project got prio above this provisioning grafana side project.
curl -X POST -u admin:somethingsecret https://dashboard.myorg.com/api/user/using/7
{"message":"Active organization changed}
However, if I run my script, I get the same error as above :-(
Code:
grafana_api = GrafanaFace(auth=(config["grafana_user"],config["grafana_pass"]),host=config["grafana_url"])
print(grafana_api.organizations.list_organization())
print(grafana_api.organization.get_current_organization())
grafana_api.organizations.switch_organization(organization_id=1)
The first two prints work fine, thus, authentication seems to work.
However, the last part, switching orgs, fails with this error:
Traceback (most recent call last):
File "provision_api.py", line 18, in <module>
grafana_api.organizations.switch_organization(organization_id=1)
File "/usr/local/lib/python3.7/site-packages/grafana_api/api/organization.py", line 132, in switch_organization
r = self.api.POST(switch_user_organization)
File "/usr/local/lib/python3.7/site-packages/grafana_api/grafana_api.py", line 136, in __request_runnner
return r.json()
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/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)
python3 --version
Python 3.7.7
pip3 install grafana_api
Requirement already satisfied: grafana_api in /usr/local/lib/python3.7/site-packages (1.0.3)
Requirement already satisfied: requests>=2.23.0 in /usr/local/lib/python3.7/site-packages (from grafana_api) (2.24.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.23.0->grafana_api) (1.25.8)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.23.0->grafana_api) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.23.0->grafana_api) (2019.11.28)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.23.0->grafana_api) (3.0.4)
from grafana_api.
Related Issues (20)
- Not able to establish Connection using pip lib grafana_api HOT 4
- Giving access denied HOT 3
- Missing permissions API HOT 1
- Support for notification channels
- Connection timeout
- folder.create_folder() doesn't create folder, but returns the list of existing folder HOT 2
- List Annotation wrong parameter name HOT 2
- json: cannot unmarshal string into Go value of type dtos.AdminCreateUserForm'}, {'fieldNames': ['Password'], 'classification': 'RequiredError', 'message': 'Required HOT 4
- create_organization("name") TypeError: string indices must be integers HOT 1
- folder/dashboard _update functions fail if not exists with overwrite=True HOT 1
- API token, Unauthorized? HOT 2
- Updating dashboards will cause them to move to the "General" folder HOT 6
- Having trouble with create_new_snapshot() function HOT 1
- Documentation links point to page that returns 404
- how to get the json of home dashboard ?
- Future maintenance of this repository and package HOT 4
- Can I duplicate a new dashboard from an existing dashboard HOT 2
- Suggestion for Improvement "get_dashboard_by_name" HOT 1
- Checking connection status HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grafana_api.