I'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.
I'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.
As long as your controller is a child of AbstractAction you can also access this data by request instance: $this->getRequest()->getHeader('APP_ID')
$this->getRequest() isn't available, so include the class \Magento\Framework\App\RequestInterface in your constructor, as explained here: mage2.pro/t/topic/235
Use this:
$httpRequestObject = new \Zend_Controller_Request_Http();
$httpRequestObject->getHeader('APP_ID');
Remember that All caps HTTP headers with underscores dropped in Apache 2.4.
Nginx:
http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
So we can try add other values. For example: AppId without underscores.
We could get the header with
\Magento\Framework\App\RequestInterface
\Magento\Framework\Webapi\Request
\Magento\Framework\HTTP\PhpEnvironment\Request