Ad Widget

Collapse

No permissions to call "host.create".

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JureSah
    Junior Member
    • Aug 2021
    • 9

    #1

    No permissions to call "host.create".

    Hello,

    I am using the Zabbix API through Ansible... it's basically python generating JSON and sending it to the API.

    My zabbix server is version 6.4 .

    I have the issue that my request is failing:
    Code:
    {
      "jsonrpc": "2.0",
      "method": "host.create",
      "id": "b7c77f0c-a027-4fe3-87a9-d7853f270cae",
      "params": {
        "host": "myserver.domain.local",
        "interfaces": [],
        "groups": [
          {
            "groupid": "2",
            "name": "Linux servers",
            "flags": "0",
            "uuid": "dc579cd7a1a34222933f24f52a68bcd8"
          }
        ],
        "status": 0
      },
      "auth": "myhexadecimalAPIkeyhere"
    }​
    (I have tried to minimize the code to avoid potential issues, but even this is not working.)

    The error I get is: No permissions to call "host.create".

    Now, ok I was willing to entertain that the permissions are somehow missing on this user, but the user is the same one I used on version 5.0 of this server before an upgrade and it worked fine. Just to be thorough though: User is in the "Zabbix administrators" group and has set Permissions "Super admin role". I have also checked the user role as per the instructions to verify it has access to host.create, but it looks like those options cannot be disabled for the Super admin role anyway.

    I have also verified that the user group has "Host permissions" to the group "Linux servers".

    I know that the API key is correct, because the code does other operations (like looking up the group data indicated in the above code sample) without issue.

    What am I missing?

    LP,
    Jure


    Last edited by JureSah; 05-12-2023, 13:18.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Want timplify even more... drop all this
    Code:
    "name": "Linux servers",
    "flags": "0",
    "uuid": "dc579cd7a1a34222933f24f52a68bcd8"
    if you are not going to add interface details, then maybe you can get away without specifying it also?
    "Status":0​ is also a default value, so no need to specify it...

    Comment

    • JureSah
      Junior Member
      • Aug 2021
      • 9

      #3
      I don't have that option since this is not my code that generates the JSON.

      If you are saying that without the uuid and other information it will work, I will open a bug report on the Ansible module with this information.

      I have tried including the interface info and I get the same error.

      LP,
      Jure

      Comment

      • JureSah
        Junior Member
        • Aug 2021
        • 9

        #4
        Okay I have tried with just a POST request:
        Code:
        {
          "jsonrpc": "2.0",
          "method": "host.create",
          "id": "b7c77f0c-a027-4fe3-87a9-d7853f270cae",
          "params": {
            "host": "myserver.domain.local",
            "groups": [
              {
                "groupid": "2"
              }
            ],
            "status": 0
          },
          "auth": "myhexadecimalAPIkeyhere"
        }
        ​
        (Also tried it without status. Same error. If I go without ID, nothing happens, but with ID set to "1", I get the same error.)

        Code:
        curl -s -X POST -H 'Content-Type: application/json-rpc' -d @request.json https://zabbix.fqdn.com/api_jsonrpc.php
        I get the same error:
        Code:
        {"jsonrpc":"2.0","error":{"code":-32500,"message":"Application error.","data":"No permissions to call \"host.create\"."},"id":"b7c77f0c-a027-4fe3-87a9-d7853f270cae"}
        LP,
        Jure
        Last edited by JureSah; 05-12-2023, 15:22.

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          As you say, it is somekind of ansible module.. those are probably tested enough, that this kind of simple mistakes would not appear, as providing too much data ...

          Do you have any other user to try it with?

          Comment

          • JureSah
            Junior Member
            • Aug 2021
            • 9

            #6
            As mentioned I tried it with curl and I have the same error.

            LP,
            Jure

            Comment

            • JureSah
              Junior Member
              • Aug 2021
              • 9

              #7
              Nevermind, issue closed.

              I'm blind. I had two users one with the uppercase username which was an admin and one with a lowercase username which was a normal user and linked my API key to the wrong one.

              I deleted the wrong user and re-created the API key. Now everything works.

              LP,
              Jure

              Comment

              Working...