CakeDC / cakephp-api

API Plugin for CakePHP
Other
61 stars 33 forks source link

$this->getData() is always empty #47

Closed birdy247 closed 6 years ago

birdy247 commented 6 years ago

On latest version of cakeapi

When we inspect $this->getData(), it is always an empty array (for POST, PUT)

We have to use this to retrieve the request payload:

$data = $this->getService()->getRequest()->input('json_decode', true);

request url /myapp/api/v1/example

headers: 'Content-Type': 'application/json', 'Accept': 'application/json'

skie commented 6 years ago

Do you including RequestHandlerMiddleware before ApiMiddleware.

birdy247 commented 6 years ago

Thanks, this solved it. Couldnt see any mention in the docs. We are using 2 pieces of middleware now, ApiMiddleware and RequestHandlerMiddleware. Are there any others we should use?

skie commented 6 years ago

No, that's all you need.