I'm trying the following code to access product list

$client = new SoapClient('http://magentohost/api/soap/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'product.list');

But this is throwing the following error -

Fatal error: Uncaught SoapFault exception: [2] Access denied.

Can anyone help me to resolve this error ?.

2 Answers 2

  • Check if the apiUser and apiKey are correct or maybe try to set a new key/password via System > Web-Services > SOAP/XML-RPC - Users.

  • Disable WSDL Cache: Under System > Configuration > Magento Core API set Enable WSDL Cache to "No".

  • Updated/debug your script:

Try to run your script with the WSDL cache disabled settings:

ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient('http://magentohost/api/soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'product.list');

The solution is to
1. create a new SOAP/XML-RPX Roles, say "Test"
2. in Role Resources just select "All" for Resource Access (just for testing)
3. Edit the user and assign the Role to "Test"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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