I want to create a Grafana organization through its API.
According to https://grafana.com/docs/grafana/latest/developers/http_api/org/
Create Organization
POST /api/orgs
Only works with Basic Authentication (username and password), see introduction.
Example Request:
POST /api/orgs HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"name":"New Org."
}
Note: The api will work in the following two ways
Need to set GF_USERS_ALLOW_ORG_CREATE=true
Set the config value users.allow_org_create to true in ini file
Example Response:
HTTP/1.1 200
Content-Type: application/json
{
"orgId":"1",
"message":"Organization created"
}
I set up the following curl command:
curl \
-H "Accept: application/json, Content-Type: application/json" \
-d '{"name":"test"}' \
-u "admin:admin" \
-X POST \
http://localhost:3000/api/orgs
Its (bad) results is:
{"message":"bad request data","traceID":""}
My /etc/environnement:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
GF_USERS_ALLOW_ORG_CREATE="true"
My /etc/grafana/grafana.ini contains:
[users]
# disable user signup / registration
;allow_sign_up = true
# Allow non admin users to create organizations
;allow_org_create = true
users.allow_org_create = true
Note that any ";something" is a Grafana default that should not need to be set, from what I understood ...
Any ideas welcome.