Ad Widget

Collapse

API/Json Syntax Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tkrn
    Junior Member
    • May 2014
    • 10

    #1

    API/Json Syntax Help

    In PowerShell, I am getting the following error No permissions to referred object or it does not exist!. I think it's related to the "hosts": block but it's not clear how it's expected since the API documentation doesn't give an example of one with multiple hostid's. Please see https://www.zabbix.com/documentation...oup/massupdate

    Any help would be awesome! Thank you!

    Code:
    PS C:\Users\adm> $JsonMassUpdateHostgroup
    {
        "method":  "hostgroup.massupdate",
        "params":  {
                       "groups":  {
                                      "groupid":  "110"
                                  },
                       "hosts":  {
                                     "hostid":  "[10106,10185,10702,11468,10228,10302,10229,10258,10289,10245,
    10750,10249,11433,10115,11429,10110,11425,11432,10105,10687,10090,10091,10116,10118,10092,10117,10119,1020
    1,10194,10674,10675,10673,10788,10976,10680,10679,10678,10672,10192,10193,10163,10164,10689,10763,10764,11
    318,11329,11325,11316,11317,11391,11424,11430,11465,11467,11584,11473,11471,11474,11676,11694]"
                                 }
                   },
        "id":  1,
        "jsonrpc":  "2.0",
        "auth":  "5edaca0cae9524e24581406a15492104"
    }
    
    
    PS C:\Users\adm> $JsonMassUpdateHostgroupResponse.error.code
    -32500
    
    PS C:\Users\adm> $JsonMassUpdateHostgroupResponse.error.data
    No permissions to referred object or it does not exist!
  • tkrn
    Junior Member
    • May 2014
    • 10

    #2
    I've also tried the following syntax, without success:

    Code:
    {"method":"hostgroup.massupdate","params":{"groups":{"groupid":"110"},"hosts":"[{"hostid":"10106"},
    {"hostid":"10185"},{"hostid":"10702"},{"hostid":"11468"},{"hostid":"10228"},{"hostid":"10302"},{"hostid":"10229"},
    {"hostid":"10258"},{"hostid":"10289"},{"hostid":"10245"},{"hostid":"10750"},{"hostid":"10249"},{"hostid":"11433"},
    {"hostid":"10115"},{"hostid":"11429"},{"hostid":"10110"},{"hostid":"11425"},{"hostid":"11432"},{"hostid":"10105"},
    {"hostid":"10687"},{"hostid":"10090"},{"hostid":"10091"},{"hostid":"10116"},{"hostid":"10118"},{"hostid":"10092"},
    {"hostid":"10117"},{"hostid":"10119"},{"hostid":"10201"},{"hostid":"10194"},{"hostid":"10674"},{"hostid":"10675"},
    {"hostid":"10673"},{"hostid":"10788"},{"hostid":"10976"},{"hostid":"10680"},{"hostid":"10679"},{"hostid":"10678"},
    {"hostid":"10672"},{"hostid":"10192"},{"hostid":"10193"},{"hostid":"10163"},{"hostid":"10164"},{"hostid":"10689"},
    {"hostid":"10763"},{"hostid":"10764"},{"hostid":"11318"},{"hostid":"11329"},{"hostid":"11325"},{"hostid":"11316"},
    {"hostid":"11317"},{"hostid":"11391"},{"hostid":"11424"},{"hostid":"11430"},{"hostid":"11465"},{"hostid":"11467"},
    {"hostid":"11584"},{"hostid":"11473"},{"hostid":"11471"},{"hostid":"11474"},{"hostid":"11676"},
    {"hostid":"11694"}]"},"id":1,"jsonrpc":"2.0","auth":"5edaca0cae9524e24581406a15492104"}

    Comment

    • tkrn
      Junior Member
      • May 2014
      • 10

      #3
      Figured it out! Removed the quotes around [...] that PowerShell automatically puts there. Then Zabbix is able to identify it's an array!



      Code:
      {"method":"hostgroup.massupdate","params":{"groups":{"groupid":"110"},"hosts":[{"hostid":"10106"},
      {"hostid":"10185"},{"hostid":"10702"},{"hostid":"11468"},{"hostid":"10228"},{"hostid":"10302"},{"hostid":"10229"},
      {"hostid":"10258"},{"hostid":"10289"},{"hostid":"10245"},{"hostid":"10750"},{"hostid":"10249"},{"hostid":"11433"},
      {"hostid":"10115"},{"hostid":"11429"},{"hostid":"10110"},{"hostid":"11425"},{"hostid":"11432"},{"hostid":"10105"},
      {"hostid":"10687"},{"hostid":"10090"},{"hostid":"10091"},{"hostid":"10116"},{"hostid":"10118"},{"hostid":"10092"},
      {"hostid":"10117"},{"hostid":"10119"},{"hostid":"10201"},{"hostid":"10194"},{"hostid":"10674"},{"hostid":"10675"},
      {"hostid":"10673"},{"hostid":"10788"},{"hostid":"10976"},{"hostid":"10680"},{"hostid":"10679"},{"hostid":"10678"},
      {"hostid":"10672"},{"hostid":"10192"},{"hostid":"10193"},{"hostid":"10163"},{"hostid":"10164"},{"hostid":"10689"},
      {"hostid":"10763"},{"hostid":"10764"},{"hostid":"11318"},{"hostid":"11329"},{"hostid":"11325"},{"hostid":"11316"},
      {"hostid":"11317"},{"hostid":"11391"},{"hostid":"11424"},{"hostid":"11430"},{"hostid":"11465"},{"hostid":"11467"},
      {"hostid":"11584"},{"hostid":"11473"},{"hostid":"11471"},{"hostid":"11474"},{"hostid":"11676"},
      {"hostid":"11694"}]},"id":1,"jsonrpc":"2.0","auth":"5edaca0cae9524e24581406a15492104"}

      Comment

      Working...