【问题标题】:Not able to create Grafana User using HTTP API无法使用 HTTP API 创建 Grafana 用户
【发布时间】:2018-11-03 11:57:17
【问题描述】:

我正在尝试使用 API 创建 grafana 用户,这就是我尝试过的。

curl -XPOST -H “Content-Type: application/json” -d '{“name”:“User”,“email”:“user@graf.com”,“login”:“user”,“密码”:“密码”}' http://admin:admin@localhost:3000/api/admin/users

得到这个:[{“分类”:“反序列化错误”,“消息”:“无效字符'\''正在寻找值的开头”},{“字段名称”:[“密码”],“分类”: “RequiredError”,“消息”:“必需”}]

谁能帮帮我?

【问题讨论】:

    标签: grafana-api


    【解决方案1】:

    我遵循http://docs.grafana.org/http_api/user/ 文档,现在我能够创建用户并能够使用所有 grafana api

    这是我的问题的答案

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

    【讨论】:

      猜你喜欢
      • 2020-04-17
      • 2015-09-18
      • 2019-11-14
      • 1970-01-01
      • 2017-10-16
      • 2016-03-06
      • 1970-01-01
      • 2019-02-25
      • 1970-01-01
      相关资源
      最近更新 更多