Ad Widget

Collapse

API - login not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StephenKing
    Junior Member
    • Sep 2011
    • 19

    #1

    API - login not working

    Hi,

    I'm unsure, if this is really related to Zabbix beta (1.9.8) or whether I'm too stupid (have no 1.8 running).

    Login with API is not working. I'm sending this request:

    Code:
    {
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": "user",
            "password": "password"
        },
        "auth": null,
        "id": 0
    }
    and zabbix responds with
    Code:
    {
      "id" : null,
      "jsonrpc" : "2.0",
      "error" : {
        "data" : "Invalid JSON. An error occurred on the server while parsing the JSON text.",
        "code" : -32700,
        "message" : "Parse error"
      }
    }
    The API changes 1.8 - 2.0 doesn't help me. I just read in the net that user.login replaces user.authenticate.

    Do you know, what I'm doing wrong? Is there any other way to debug? Setting Zabbix server log severity to 4 (Debug) didn't help..

    Thanks for your response
    Steffen
  • zalex_ua
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2009
    • 1286

    #2
    Originally posted by StephenKing

    Code:
    {
         "auth": null,
    }
    That part could be excess in the request.
    See documentation example: http://www.zabbix.com/documentation/...api/user/login

    Comment

    • StephenKing
      Junior Member
      • Sep 2011
      • 19

      #3
      Thanks for your reply, but the "auth" doesn't matter (nothing changes, if it's omitted).

      Comment

      • my36
        Junior Member
        • Dec 2011
        • 11

        #4
        Perhaps try
        method: "user.authenticate"

        Comment

        • StephenKing
          Junior Member
          • Sep 2011
          • 19

          #5
          Thanks for your reply. user.authenticate has been renamed to user.login (see Zabbix 2.0 docs). And I tried this, too..

          I'm really wondering, what I'm doing wrong. Do I have to enable anything in Zabbix itself?

          Thanks for your help
          Steffen

          Comment

          • my36
            Junior Member
            • Dec 2011
            • 11

            #6
            user.authenticate works for me in 1.9.8

            You also have to have a user with all the permissiones required. I'd try it using
            a super admin user with every concievable permission just to make sure it's not
            a user permission thing.

            Comment

            • StephenKing
              Junior Member
              • Sep 2011
              • 19

              #7
              Thanks my36.

              Yes, both authenticate and login should work according to the docs.

              I've just digged into the code. CJSONrpc::_construct($jsonData) is called with empty $jsonData, which causes the parse error. However, I have no clue, why the function is called without data...

              Steffen

              Comment

              • StephenKing
                Junior Member
                • Sep 2011
                • 19

                #8
                Ah, okay.. miracle solved.. the body of the CHTTP_request was empty, which was (well..) caused because I've sent it through a GET request.

                Of course, it's my own stupidity, but the CocoaRestClient I was using made it too easy to me, to enter a request body, without reminding me that this should be POST then

                Now everything works, thanks for trying to help me!

                Comment

                Working...