1

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
Content-Type:application/json

Payload

{"name":"shahal","form_key":"3j7DhIGtPqIRkpyD"}

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?

IMPORTANT

I cannot change the structure of the incoming requests.

asked Oct 30, 2013 at 16:41

1 Answer 1

1

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.

answered Oct 31, 2013 at 16:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.