Ad Widget

Collapse

Need help with API

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • fjrial
    replied
    Yes; I'm using http auth.

    I'm already following the zbx-2078 issue.

    But I couldn't get it work using the patch provided in the issue.

    Any other clue?

    Thanks

    Leave a comment:


  • gpmidi
    replied
    HTTP Auth

    Are you using HTTP authentication or LDAP authentication on the Zabbix server? If so ZBX-2078 may be the problem. A more detailed description of the exact nature of the problem is in this forum post.
    Last edited by gpmidi; 11-03-2010, 16:29. Reason: Added more details

    Leave a comment:


  • fjrial
    replied
    I tried with all those changes, but with no success.

    I'm using zabbix 1.8.1 and I'm developing a third party app with PHP which uses some functionality from zabbix and I need to use the api.

    Using jsonRPCClient, and verified all requirements.

    Could this be the problem: http://www.zabbix.com/forum/showthread.php?p=59515 ?

    Thanks for your help

    Leave a comment:


  • nelsonab
    replied
    Code:
    {
    "auth":null,
    "method":"user.authenticate",
    "id":0,
    "params":{"password":"pass","user":"me"},
    "jsonrpc":"2.0"
    }
    The above was taken from a debug statement from Zabcon. Try adding a blank authentication token to your statement. As for placing the id value inside tick marks, doing so will make the API end interpret the value as a string not an integer.

    Leave a comment:


  • yaap
    replied
    Originally posted by fjrial
    Anyone finds the solution for that piece of code (the one from the beginning of the thread) to work?
    Did you try add apostrophes to ID value ?

    $a = $o->exec ("{'jsonrpc': '2.0',
    'method': 'user.authenticate',
    'params': {'user': 'admin', 'password': 'my_password'},
    'id': '1'
    }");

    Leave a comment:


  • fjrial
    replied
    Anyone finds the solution for that piece of code (the one from the beginning of the thread) to work?

    Leave a comment:


  • Farley
    replied
    Posted my API...

    The API I was talking about is now posted for public consumption at the URL below. Even if you don't want to use it, view the code, it's relatively simple to consume the Zabbix API with a recent version of PHP.

    Enjoy!

    Leave a comment:


  • decksta
    replied
    So I finally made some headway. The user making API calls not only needs to be API enabled but also a superadmin for the host.get and item.get type requests to return anything.

    The docs on all this are nonexistent so good luck!~

    Leave a comment:


  • Russ
    replied
    Originally posted by decksta
    I have some Java code working (although not the item and host get methods) if you'd like to see that. What helped me greatly was the Zabcon source and setting the debug level to 10. You can see how the JSON requests are formed and mimic that via your preferred API (I am using JSON Java to marshall and unmarshall JSON objects).

    Also, another gotcha with authentication is that the user must be enabled for API access in Zabbix.
    I may have another look at Zabcon, with the debug level increased. I tried looking at it earlier, but it didn't help. Being able to see the JSON requests might be useful.

    Originally posted by Farley
    Russ... I'm working on a PHP Class to consume the Zabbix API, interested in being my first beta tester?

    PM me.
    PM sent. Thanks

    Russ

    Leave a comment:


  • Farley
    replied
    Wanna test out my class?

    Russ... I'm working on a PHP Class to consume the Zabbix API, interested in being my first beta tester?

    PM me.

    Cheers,

    Leave a comment:


  • decksta
    replied
    Originally posted by Russ
    Could you post your working code, please? It might help me get started.

    Russ
    I have some Java code working (although not the item and host get methods) if you'd like to see that. What helped me greatly was the Zabcon source and setting the debug level to 10. You can see how the JSON requests are formed and mimic that via your preferred API (I am using JSON Java to marshall and unmarshall JSON objects).

    Also, another gotcha with authentication is that the user must be enabled for API access in Zabbix.

    Leave a comment:


  • nelsonab
    replied
    Originally posted by Russ
    Could you post your working code, please? It might help me get started.

    Russ
    Check out the Zabcon site, the link is below. Now that my personal life has settled a little bit (just moved from California to East Coast) I'll be working on getting Zabcon up to snuff and the API, along with some documentation to help understand the API.

    Right now if you click on "browse source" on the Zabcon site and go into the ruby/api/zbx_api.rb file you will see the basics of how the API is used.

    Leave a comment:


  • Russ
    replied
    Originally posted by decksta
    I've been playing with 1.8 and it seems the host.get and item.get methods are returning nothing. I've logged in correctly and passed the auth token to subsequent requests. Interestingly (or not) the user.get works fine.
    Could you post your working code, please? It might help me get started.

    Russ

    Leave a comment:


  • decksta
    replied
    I've been playing with 1.8 and it seems the host.get and item.get methods are returning nothing. I've logged in correctly and passed the auth token to subsequent requests. Interestingly (or not) the user.get works fine.

    Is this a known issue?

    (FWIW, I've tested these methods with Zabcon and they return the same thing: nothing)

    Leave a comment:


  • nelsonab
    replied
    Your JSON call looks to be good but this looks to be a bug similar to one we were working on in the last stages of the Beta. I'll try and have a look at the portion of the Zabbix code when I can and get back to you.

    Leave a comment:

Working...