1

I'm trying to access magento product catalog data using magento API.

I'm trying sample code provided by magento

$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call($session, 'catalog_product.list');
var_dump($result);

// If you don't need the session anymore
//$client->endSession($session);

All the API(s) are working fine expect the catalog product list.

I'm getting following error.

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Call to a member function getRole() on null in G:\wamp64\www\mage-api\index.php on line 11
( ! ) SoapFault: Call to a member function getRole() on null in G:\wamp64\www\mage-api\index.php on line 11

I have created API user with full access role and it's working fine with all the API expect catalog list.

Any solution ? Thanks in advance.

  • I think You have not created role in admin @Ashvini Maewal – Learing_Coder Jun 20 '17 at 4:49
1

I had the same issue and after a long debugging session, I found out that the error is caused by the extension MagentoHackathon_AdvancedAcl. I opened an issue and created a pull request, which fixes this issue.

The problem is that they execute the following code:

Mage::getSingleton('admin/session')->getUser()->getRole();

But in the case of a SOAP API call, there is no user in the admin session.

0

you have to follow the below Steps to Create the Api User & Api Key

https://www.yireo.com/tutorials/magebridge/administration/596-step-by-step-create-a-magento-api-user

Then you have to use Api key & User name in your Code below

$session = $client->login('apiUser here you have to change user name ', 'apiKey here you have to change key ');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.