ZF: Zend_Rest_Client::restDelete() ‘Unexpected error: No Method Specified’

When using Zend_Rest_Client & Zend_Rest_Server with ZF v1.10.2, to quickly build a Rest webservice, performing simple restDelete() queries ended up with following error message:

Unexpected error: No Method Specified

In fact, current implementation of Zend_Rest_Client::restDelete() does not provide any request parameter to queried url.
On server side, Zend_Rest_Server expects the ‘method’ argument to be provided => above error is generated.

To avoid this problem, I had to update Zend_Rest_Client with following updated method:

/**
* Performs an HTTP DELETE request to $path.
*
* @param string $path
* @param array $query Array of GET parameters
* @throws Zend_Http_Client_Exception
* @return Zend_Http_Response
*/
final public function restDelete($path, $query = null)
{
$this->_prepareRest($path);
$client = self::getHttpClient();
$client->setParameterGet($query);
return $client->request('DELETE');
}

note: subclassing the class was not an option since most of its methods are ‘final’! Grrrr…

For more information, look at corresponding tickets (see links below)

sources

Post a Comment

Your email is never published nor shared. You're allow to say what you want...

Powered by sweet Captcha