I am trying to send a POST request to a controller with JSON payload. Relevant request details are as follows.

Request URL:http://mag.local/index.php/shahal/test/saveJson
Request Method:POST



Rather than going to appropriate controller, it redirect the request to the dashboard. I assume its because Magento doesn't decode JSON string and read the form_key from the request body. Is there any other workaround for this issue? Or is there a straightforward method for JSON requests in magento?


I cannot change the structure of the incoming requests.


Not changing the input is really hacky, because the mistake is made by the form of the request.

That said, you can implement an observer before the check (predispatch?) and get the form_key from the json and put it into the request parameters.

| 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.