GDP
GDP

Reputation: 8178

How to map Restler classes to POST method instead of GET?

I've used Restler v2 for years, and have finally started to work with v3. In v2, it seemed to simply be a matter of preceding the function name with get or post for it to be visible only to the specified method.

I'm still trying to understand how v3 implements the DocBLock comments to control all of this, and am simply unable to determine the correct way to make the API visible only with POST. I've been reading Routing Example, but am clearly missing something in the explanation.

I've tried variations of most everything shown on the example below as the starting point. It authenticates and works perfectly fine with GET - How do I make it visible only with POST? The error I get is typically 404 - not found, unless the DocBlock variations cause a general PHP error of some kind.

/**
* @param string $action {@from path}
* @param string $service {@from path}
*
* @return array
*/
protected function Perform ($action, $service)
{
...
}

Upvotes: 2

Views: 60

Answers (1)

GDP
GDP

Reputation: 8178

As it turns out, a POST isn't just a POST....I was using the GET method with my browser and AJAX to test the API. When I switched AJAX to use POST, I didn't specify the datatype for the post. Once I did that, adding the post prefix worked as expected.

Upvotes: 0

Related Questions