I am sending a CURL request to a controller action and construct() function is working(calling) but it doesn't call the execute() function of the controller.

For now, I am calling the execute() function within the construct() myself as below. Also, let me know if it is not a recommended way.

public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
) {
    $this->resultJsonFactory = $resultJsonFactory;

Any help will be appreciated. Thanks in Advance :)


First, it's not the recommended way. If your application need to talk to Magento, the best way to use Rest/GraphQl API for this.

See, official documentation. https://devdocs.magento.com/guides/v2.4/get-started/bk-get-started-api.html

Actually, all that you need is create class and then map methods of thous class to some endpoint in webapi.xml

  • Actually I am implementing a Custom Payment module and A curl call will be triggered from the Payment server to Magento in a case So that It is necessary for me to handle that curl call. If I use Rest API few functions are not working properly. Is there any other way to do this. Jun 10 '20 at 5:58

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.