Zimbra API error

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
pisavi
Posts: 4
Joined: Tue May 16, 2017 1:44 pm

Zimbra API error

Postby pisavi » Tue May 16, 2017 2:31 pm

I'm using https://github.com/zimbra-api/zimbra-api as a php api wrapper, following these rules https://files.zimbra.com/docs/soap_api/8.7.0/api-reference/index.html.
Some of the call works (getAccountInfo, getDomainInfo) but others don't, like GetAllAccounts.

Here's that part of code:

Code: Select all

<?php
$mUsername = '*****@*******.com';
$mPassword = '**************************';
$api = \Zimbra\Admin\AdminFactory::instance('https://********:7071/service/admin/soap');
$logauth = $api->auth($mUsername, $mPassword);

$mDomain = '*******';

$domain = new \Zimbra\Admin\Struct\DomainSelector(\Zimbra\Enum\DomainBy::VIRTUAL_HOSTNAME(), $mDomain);
$server = new \Zimbra\Admin\Struct\ServerSelector(\Zimbra\Enum\ServerBy::SERVICE_HOSTNAME(), $mDomain);

$myVar= $api->getallaccounts($domain, $server);



Even though $domain and $server are 100% correct, i get this error:

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `POST https://*************:7071/service/admin/soap` resulted in a `500 Server Error` response: <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><change tok (truncated...) ' in /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/ZimbraApi/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Pro in /var/www/ZimbraApi/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

What can I do?


ajcody
Advanced member
Advanced member
Posts: 50
Joined: Fri Sep 12, 2014 11:26 pm
Location: Michigan
Contact:

Re: Zimbra API error

Postby ajcody » Wed May 17, 2017 2:46 pm

There's a chance that the code wasn't updated to use "zmprov -l gaa" vs "zmprov gaa". I forget which version of ZCS is was, but there was a change where -l was required for gaa to work.
pisavi
Posts: 4
Joined: Tue May 16, 2017 1:44 pm

Re: Zimbra API error

Postby pisavi » Wed May 17, 2017 2:58 pm

ajcody wrote:There's a chance that the code wasn't updated to use "zmprov -l gaa" vs "zmprov gaa". I forget which version of ZCS is was, but there was a change where -l was required for gaa to work.


Hi, thanks for your answer.
Unfortunately, searching trough the files, I can see that the wrapper doesn't use zmprov or gaa.
Am I doing something wrong?
iomarmochtar
Posts: 41
Joined: Sat Sep 13, 2014 3:54 am
Location: Indonesia
Contact:

Re: Zimbra API error

Postby iomarmochtar » Sun May 28, 2017 3:59 pm

you may change max search result configuration if you have more than 5000 account.

run this command in (each) mailbox server, for instance allow max to 10000

su - zimbra
zmlocalconfig -e zimbra_directory_max_search_result=10000
zmcontrol restart

the better way to fetch list of user is through ldap, that's why zmprov for fetching all user (getAllAccounts or gaa) require -l .
pisavi
Posts: 4
Joined: Tue May 16, 2017 1:44 pm

Re: Zimbra API error

Postby pisavi » Mon May 29, 2017 7:48 am

iomarmochtar wrote:you may change max search result configuration if you have more than 5000 account.

run this command in (each) mailbox server, for instance allow max to 10000

su - zimbra
zmlocalconfig -e zimbra_directory_max_search_result=10000
zmcontrol restart

the better way to fetch list of user is through ldap, that's why zmprov for fetching all user (getAllAccounts or gaa) require -l .


Thanks for your help, but I am not even close to 5000 accounts so that might not be the problem
iomarmochtar
Posts: 41
Joined: Sat Sep 13, 2014 3:54 am
Location: Indonesia
Contact:

Re: Zimbra API error

Postby iomarmochtar » Mon May 29, 2017 8:25 am

For testing purpose you can try my own zimbra API library.

https://gist.github.com/iomarmochtar/b9 ... 3133730ba7


just install python-requests module then modify in the bottom of file as your environment then use gaa method for fetch all users.

eg:

Code: Select all

   zmprov = ZMPROV(
       username='admin',
       password='passwd123',
       soapurl='https://192.168.1.30:7071/service/admin/soap',
       # isdebug=True
   )

   pprint( zmprov.gaa()  )


execute the script

python ozsoap.py

if the script is running well then you may trace the problem within PHP library that you use.
pisavi
Posts: 4
Joined: Tue May 16, 2017 1:44 pm

Re: Zimbra API error

Postby pisavi » Wed May 31, 2017 11:56 am

iomarmochtar wrote:For testing purpose you can try my own zimbra API library.

https://gist.github.com/iomarmochtar/b9 ... 3133730ba7


just install python-requests module then modify in the bottom of file as your environment then use gaa method for fetch all users.

eg:

Code: Select all

   zmprov = ZMPROV(
       username='admin',
       password='passwd123',
       soapurl='https://192.168.1.30:7071/service/admin/soap',
       # isdebug=True
   )

   pprint( zmprov.gaa()  )


execute the script

python ozsoap.py

if the script is running well then you may trace the problem within PHP library that you use.


Thanks you I am using your API library now, works perfectly.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 4 guests