Ad Widget

Collapse

Permission denied for item delete through API.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jefftang
    Junior Member
    • Apr 2010
    • 6

    #1

    Permission denied for item delete through API.

    I'm trying to synchronize a bunch of tasks into zabbix items via the api. The API is working fine for me, but I can't delete items through the API. ([ CItem::delete ] No permissions !). I can create them and list them, but I get "No Permissions" when I tried to delete them.

    The API user I'm using can delete the item through the GUI.

    I wanted to check here before I report a bug.

    I'm using Zabbix 1.8.8.

    I'm accessing the api throug a modified Zabbix.pm, which is just a thin wrapper around JSON::XS. Here's the debug output from a test script I wrote, which creates an item then tries to delete it:
    Code:
    request is: $VAR1 = {
              'auth' => 'a2b281ef47aa34107ff81240ad98af95',
              'params' => {
                            'key_' => 'pman.testitem.19503',
                            'applications' => [],
                            'hostid' => '10457',
                            'description' => 'Pman key for proc'
                          },
              'jsonrpc' => '2.0',
              'id' => 3,
              'method' => 'item.create'
            };
    result is: $VAR1 = {
              'jsonrpc' => '2.0',
              'id' => 3,
              'result' => {
                            'itemids' => [
                                           '131947'
                                         ]
                          }
            };
    
    
    request is: $VAR1 = {
              'auth' => 'a2b281ef47aa34107ff81240ad98af95',
              'params' => {
                            'itemids' => [
                                           '131947'
                                         ]
                          },
              'jsonrpc' => '2.0',
              'id' => 4,
              'method' => 'item.delete'
            };
    result is: $VAR1 = {
              'jsonrpc' => '2.0',
              'error' => {
                           'data' => '[ CItem::delete ] No permissions !',
                           'message' => 'Application error.',
                           'code' => -32500
                         },
              'id' => 4
            };
    Is there something I don't understand about permissions? Or should I report this as a bug.

    Thanks,

    Jeff
  • jefftang
    Junior Member
    • Apr 2010
    • 6

    #2
    I just tried it with a different user of Zabbix Super Admin type and got the same results.

    Comment

    • jefftang
      Junior Member
      • Apr 2010
      • 6

      #3
      Never mind. I read the documentation more carefully. I need to set

      params to [ Ritemid ]

      instead of to { itemids:[$itemid]}

      Comment

      • mcmyst
        Member
        • Feb 2012
        • 72

        #4
        I have the same problem and I can't find the solution :

        Code:
        {"params": 
            {"itemids": ["27096"]}, 
            "jsonrpc": "2.0", 
            "method": "item.delete", 
            "auth": "ecbef1664a2728e338d32698efc90b0e",
            "id": 1}
        
        {
            u'jsonrpc': u'2.0',
            u'id': 1, 
            u'error': {
                u'message': u'Application error.',
                u'code': -32500,
                u'data': u'[ CItem::delete ] No permissions !'
            }
        }
        I tried to replace itemids by Ritemids but this is the same...

        Comment

        • mcmyst
          Member
          • Feb 2012
          • 72

          #5
          Here is the solution in python

          Wrong way:
          Code:
          delete_item = ["27096"]
          print zapi.item.delete({"itemids":delete_item})
          Right way:
          Code:
          delete_item = ["27096"]
          print zapi.item.delete(delete_item)

          Comment

          • fizwit
            Junior Member
            • Jan 2014
            • 3

            #6
            pyzabbix item.delete No permissions

            Can not get item.delete to work. All *.get commands from pyzabbix work correctly but can not delete an item, host etc...

            Env:
            pyzabbix-0.7.2
            Zabbix 2.2.3
            python 2.6.6

            Code fragment
            zapi = ZabbixAPI( zabbix_url )
            zapi.login(username, password )can
            print "Connected to Zabbix API Version %s" % zapi.api_version()
            itemList = []
            itemList.append(itemid)
            print zapi.item.delete(itemList)

            ------- output -------
            Connected to Zabbix API Version 2.2.3
            Traceback (most recent call last):
            File "./item.delete.py", line 26, in <module>
            print zapi.item.delete(itemList)
            File "/usr/lib/python2.6/site-packages/pyzabbix-0.7.2-py2.6.egg/pyzabbix/__init__.py", line 154, in fn
            args or kwargs
            File "/usr/lib/python2.6/site-packages/pyzabbix-0.7.2-py2.6.egg/pyzabbix/__init__.py", line 131, in do_request
            raise ZabbixAPIException(msg, response_json['error']['code'])
            pyzabbix.ZabbixAPIException: ("Error -32602: Invalid params., No permissions to referred object or it does not exist! while sending {'params': (['53351'],), 'jsonrpc': '2.0', 'method': 'item.delete', 'auth': u'0a2309f7fb1d28eeec522108680b3ee3', 'id': 2}", -32602)

            Comment

            Working...