Search code examples
grafana-api

Not able to create Grafana User using HTTP API


I am trying to create the grafana users using API's and this is what I tried.

curl -XPOST -H “Content-Type: application/json” -d ‘{“name”:“User”,“email”:“[email protected]”,“login”:“user”,“password”:“password”}’ http://admin:admin@localhost:3000/api/admin/users

got this: [{“classification”:“DeserializationError”,“message”:“invalid character ‘\’’ looking for beginning of value”},{“fieldNames”:[“Password”],“classification”:“RequiredError”,“message”:“Required”}]

Can any one help me?


Solution

  • I followed the http://docs.grafana.org/http_api/user/ documentation and now I am able to create the users and able to use all grafana api's

    Here is the answer for my question

    import requests
    url='http://admin:admin@localhost:3000/api/admin/users'
    data='''{
      "name":"tester",
      "email":"[email protected]",
      "login":"tester",
      "password":"test@123"
    }'''
    headers={"Content-Type": 'application/json'}
    response = requests.post(url, data=data,headers=headers)
    print (response.text)