zimbra-api / soap-api

Zimbra SOAP client in PHP language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CreateAccount not working passing attributes

alessiosais opened this issue · comments

Good morning

I have the following code:

$api = \Zimbra\Admin\AdminFactory::instance('https://address:9071/service/admin/soap'); 
$api->auth('user@example.tld', 'password'); /* Auth */
$pair = new \Zimbra\Struct\KeyValuePair('zimbraCOSId', 'b79ebbe0-f188-4574-8bc3-d6a738db45e0'); /* new KeyValuePair instance */
$api->CreateAccount('newaccount@example.tld', 'password', [$pair]);

It raise following exception:

PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: POST https://address:9071/service/admin/soap' resulted in a 500 Server Error response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">soap:Header<change tok (truncated...)
' in /home/asais/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/asais/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /home/asais/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#4 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /home/asais/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /home/asais/vendor/guzzlehttp/guzzle/src/Client.php(131): GuzzleHttp\Promise\Promise->wait()
#10 /home/asais/vendor/zimbra-api/soap-api/src/Zimbra/Soap/Client/Http.php(143): GuzzleHttp\Client->request('POST', 'https://address:9071...', Array)
#11 /home/asais/vendor/zimbra-api/soap-api/src/Zimbra/Soap/Client/Http.php(265): Zimbra\Soap\Client\Http->__doRequest('<?xml version="...', Array)
#12 /home/asais/vendor/zimbra-api/soap-api/src/Zimbra/Admin/Base.php(767): Zimbra\Soap\Client\Http->doRequest(Object(Zimbra\Admin\Request\CreateAccount))
#13 /home/asais/testAPI.php(19): Zimbra\Admin\Base->createAccount('newaccount@example.tld', 'password', Array)
#14 {main}

My Zimbra version is 8.7.0.


Account doesn't exist and when created without passing [$pair]:

$api->CreateAccount('newaccount@example.tld', 'password');

it is correctly created.

Obviously I delete account and recreate it everytime I need to try to create it, but with given $pair it doesn't work.

Not an issue, resolve. My Zimbra admin account had not permission to assign COS.

I apologize, can close this issue. I suggest to improve Response Error, so in that way a developer can understand which error has raised.