Magento – How to get Custom HTTP header in Magento2 controller

apimagento2PHPpostmanrest

enter image description hereI'm accessing my controller via postman tool (Postman)

I've passed custom header as shown in image and trying to access it in controller through this code:

$this->_response->getHeader('APP_ID');

but it returns no data. Please Help.

Best Answer

Finally, got the solution

$httpRequestObject = new \Zend_Controller_Request_Http();
$httpRequestObject->getHeader('APP_ID');

Thank you!

Related Topic