zimbra-api / soap-api

Zimbra SOAP client in PHP language
BSD 3-Clause "New" or "Revised" License
63 stars 50 forks source link

CreateAccount not working passing attributes #26

Closed alessiosais closed 6 years ago

alessiosais commented 6 years ago

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:

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('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.
alessiosais commented 6 years ago

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.

JoepEtes commented 1 month ago

I have the same issue. Creating an account does work, but my SOAP API does not save any attributes. How did you solve it?