I am trying to create new customer using magento soap api , here is my code :
 $client = new SoapClient('http://map.itgprojects.pw/api/v2_soap?wsdl=1');
 `$session = $client->login('mylogiin',` 'myapikey');
 $result = $client->customerCustomerCreate($session, ['email' => '[email protected]', 'firstname' => 'Dough', 'lastname' => 'Deeks', 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1]);
 var_dump ($result);
I keep getting this error and I don't know why, even if the user has been added to the database :
Uncaught SoapFault exception: [SOAP-ENV:Server] Call to a member function getUserId() on null in /home/mapitgprojects/public_html/api/customer.php:51
version of magento : 1.9
I am working on an ionic app and I'am creating a web service to do some stuff.
Thank you for your help
- 
 Please try the code which is in answer.Aditya Shah– Aditya Shah2018年09月28日 16:07:10 +00:00Commented Sep 28, 2018 at 16:07
- 
 I'm using SOAP V2, but I tried your answer it didn't work , I'm having the same error : Call to a member function getUserId() on nullHanane– Hanane2018年09月28日 16:18:46 +00:00Commented Sep 28, 2018 at 16:18
- 
 Hi, please check updated answerAditya Shah– Aditya Shah2018年09月28日 16:29:57 +00:00Commented Sep 28, 2018 at 16:29
- 
 Is it your first soap api ?Aditya Shah– Aditya Shah2018年09月28日 16:30:08 +00:00Commented Sep 28, 2018 at 16:30
- 
 yes it is my first, I 'm having the same error with ur updated answer. I can retrieve list of customers with customerCustomerList but i can't add a new oneHanane– Hanane2018年09月28日 16:48:16 +00:00Commented Sep 28, 2018 at 16:48
1 Answer 1
$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
// If some stuff requires api authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->customerCustomerCreate($session, array('email' => '[email protected]', 'firstname' => 'Dough', 'lastname' => 'Deeks', 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1));
var_dump ($result);
Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');
// If somestuff requires api authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session,'customer.create',array(array('email' => '[email protected]', 'firstname' => 'Dough', 'lastname' => 'Deeks', 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1)));
var_dump ($result);
// If you don't need the session anymore
//$client->endSession($session);