I am using Magento controller URL with Postman. When I select Get Method in postman then it runs perfectly with execute method. But when I use the Post Method that time it breaks from the execute() method. It means for the Post method, the execute method, not works.

Any idea for this issue? my code is

namespace Lucent\SocialLogin\Controller\Login;

class Test extends \Magento\Framework\App\Action\Action

    protected $_customer;
    protected $_customerSession;

    public function __construct(
    \Magento\Framework\App\Action\Context $context, 
    \Magento\Customer\Model\Customer $customer,
    \Magento\Customer\Model\Session $customerSession

        $this->data = $_REQUEST;
        $this->_customer = $customer;
        $this->_customerSession = $customerSession;
        return parent::__construct($context);

    public function execute()
        //$postData = $this->getRequest()->getPost();
        echo '1';

  • can you please share your code? – Mohit Rane Jul 25 '19 at 13:38
  • try this $this->getRequest()->getPostValue(); also try to print $this->getRequest()->getParams(); – Mohit Rane Jul 25 '19 at 13:42
  • if that doesn't work try using Magento\Framework\App\RequestInterface – Mohit Rane Jul 25 '19 at 13:42
  • tried both but not goes into execute function mate – sarvesh Dineshkumar Patel Jul 25 '19 at 13:47
  • you are using this code for frontend or backend? also share the screenshot of error. – Mohit Rane Jul 25 '19 at 13:49

I got a solution here. When I trying with $.post() method that time no need of form_key.

But, When I trying with var xhttp = new XMLHttpRequest(); with post method then form_key mandatory so that is why $_POST data not getting so quit from it.

Thanks all whoever supports.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.