I keep receiving this error in my exception log:
2016-10-14T09:20:43+00:00 ERR (3):
exception 'Mage_Core_Exception' with message 'Invalid webservice adapter specified.' in /homepages/22/d123456/htdocs/mysite/app/Mage.php:595
Stack trace:
#0 /homepages/22/d123456/htdocs/mysite/app/code/core/Mage/Api/Model/Server.php(127): Mage::throwException('Invalid webserv...')
#1 /homepages/22/d123456/htdocs/mysite/api.php(84): Mage_Api_Model_Server->initialize(NULL)
#2 {main}
Also, this line is uncommented in my .htaccess:
###########################################
## rewrite API2 calls to api.php (by now it is REST only)
RewriteRule ^api/rest api.php?type=rest [QSA,L]
Best Answer
Your stack trace is showing that something odd is definitely afoot.
The key thing I'm seeing is that you are calling
Mage_Api_Model_Server->initialize(NULL)
.This function is defined like
If you pass in
null
, you are definitely not going to be selecting a valid adapter as$adapters[null]
will not be a valid index key. I'm pretty surenull
will be cast to the empty string in this instance, but there will not be any active adapters with the code of an empty string (or at least I hope not!)The
api.php
file tries to call this initialise function like following (code edited for brevity).Based on your stack trace something is going wrong here and the final $adapterCode is ending up as
null
. The section of code which does thenull === $adapterCode
check will set the$adapterCode
to be the value of yourtype
parameter in the event thatgetAdapterCodeByAlias
has returnednull
. This means that even ifgetAdapterCodeByAlias
is returningnull
, it will ignore the value from that function so it can be disregarded from your issue.The only way that I can see that
$adapteCode
will end up asnull
is ifMage::app()->getRequest()->getParam('type');
returnsnull
. This is exactly howgetParam
is defined, it defaults tonull
if the parameter is missing.All this boils down to the fact that you will likely be trying to access the api method without supplying a valid
type
parameter. This is an indication that your.htaccess
file isn't configured properly. Try manually requesting with thetype
parameter, or get a systems admin to help figure out why the rewrite rules are not firing for you.The valid types for me on a 1.14 magento instance are