Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API error -32602: The "user.login" method must be called without the "auth" parameter. #2

Open
hexistore opened this issue May 22, 2015 · 4 comments

Comments

@hexistore
Copy link

I run it return this error,can you help me?

My zabbix server version is v2.4.5

@lpkone
Copy link

lpkone commented Jun 17, 2015

Same error. Please help

@pndiku
Copy link

pndiku commented Jul 16, 2015

Zabbix's API changed (https://support.zabbix.com/browse/ZBX-7781) and this code wasn't updated.

Here's a patch that works for me:

diff --git a/lib/php/PhpZabbixApi_Library/ZabbixApiAbstract.class.php b/lib/php/PhpZabbixApi_Library/ZabbixApiAbstract.class.php
index fde99d9..c8ea993 100644
--- a/lib/php/PhpZabbixApi_Library/ZabbixApiAbstract.class.php
+++ b/lib/php/PhpZabbixApi_Library/ZabbixApiAbstract.class.php
@@ -208,13 +208,22 @@ abstract class ZabbixApiAbstract
         $this->id = number_format(microtime(true), 4, '', '');

         // build request array
-        $this->request = array(
-            'jsonrpc' => '2.0',
-            'method'  => $method,
-            'params'  => $params,
-            'auth'    => ($auth ? $this->auth : ''),
-            'id'      => $this->id
-        );
+        if (!$auth) {
+           $this->request = array(
+                'jsonrpc' => '2.0',
+                'method'  => $method,
+                'params'  => $params,
+                'id'      => $this->id
+            );
+        } else {
+            $this->request = array(
+                'jsonrpc' => '2.0',
+                'method'  => $method,
+                'params'  => $params,
+                'auth'    => $this->auth,
+                'id'      => $this->id
+           );
+        }

         // encode request array
         $this->requestEncoded = json_encode($this->request);

@agperson
Copy link
Owner

Looks like this was fixed upstream in confirm/PhpZabbixApi#13 -- If you would like to submit a PR to either update the included version of the library or switch to pulling down the latest using Composer I would happily merge it.

@thomasgogo
Copy link

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants