2

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,

1 Answer 1

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!

7
  • Thnaks for your help Commented Feb 15, 2020 at 15:17
  • Thanks @CarlosHernanAguilarHurtado. Please upvote my answer if it really helped you. Commented Feb 16, 2020 at 16:36
  • 1
    Thanks @PatrickW: one upvote from me as well as it worked like a charm for me. Thanks. Commented Mar 14, 2020 at 4:33
  • @PratikNavapara i am also facing same issue, and i added this code also, but still getting same error. Commented Oct 9, 2020 at 10:06
  • @sam, this should be working fine. Sorry but I don't know any other solution for this error. Commented Oct 12, 2020 at 5:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.