1

I have created one front controller in my project in order to receive data from third party webhook (e.g. sendgrid). However, when webhook access this url magento logs below error in debug.log file

Request validation failed for action "Namespace\Modulename\Controller\Email\Index\Interceptor" [] []

Does anyone has idea regarding this? I already gone through couple of stack overflow solutions but it didn't work.

Thanks,

2

Yes, I got the solution. Sorry for late reply.

This issue generally comes when some parameters are not passing through the request which your controller serves and used to validate that specific request. So if you know those exact parameters then you can simply add it while calling controller from third party service.

Or you need to bypass the validations done by magento while accessing controller from third party service. In order to do that you need to write below 2 functions in your controller.

    public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
    {
        return null;
    }

    public function validateForCsrf(RequestInterface $request): ?bool
    {
        return true;
    }

This will resolved your issue.

That's all!

| improve this answer | |
  • Thnaks for your help – Carlos Hernan Aguilar Hurtado Feb 15 at 15:17
  • Thanks @CarlosHernanAguilarHurtado. Please upvote my answer if it really helped you. – Pratik Navapara Feb 16 at 16:36
  • 1
    Thanks @PatrickW: one upvote from me as well as it worked like a charm for me. Thanks. – Narendra Vyas Mar 14 at 4:33

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.