I am developing an API using CakePHP 3 framework. Now I am sending a GET request from the POSTMAN client. The user will pass the API key in the header. 
I want to get this header in my controller function.
This is what my controller looks like
namespace Api\Controller; use Cake\Auth\DefaultPasswordHasher; use Api\Controller\AppController; use Cake\Cache\Cache; use Cake\Http\ServerRequest; class ApiController extends AppController { public function initialize() { parent::initialize(); $this->loadComponent('RequestHandler'); } public function myinfo() { if($this->request->is('get')) { $key = $this->request->getHeaderLine('Authorization'); $this->set('key', $key); } $this->set('_serialize', ['key']); } }
The error I get is: HeaderLine is not a function
I also tried some more options:
$acceptHeader = $this->request->getHeader('Authorization');
but it also gave rise to a similar error. The header is not a function.
Link: Link
CakePHP Version: 3.3.5
source share