I created my custom Controller for POST request, but i all time have empty response.

    $testIds = $this->request->getPost('test');
    $items = [];
    foreach ($testIds as $id) {
        $items[$id] = [
            'test' => $id,

    if (count($items)) {
        $response = [
            'success'   => true,
            'items'     => $items
    } else {
        $response = [
            'success'   => false,
            'message'   => __('False')

    $resultJson = $this->jsonFactory->create();

    return $resultJson;

My Controller implements Magento\Framework\App\Action\HttpPostActionInterface.

How i can fix it?


1 Answer 1


In general, HTTP responses of 500 will write an error to the Magento log if it is a Magento issue, and will not write to the Magento log if it is not a Magento issue. So first check the log:

$ cd /path/to/magento/installation
$ tail var/log/system.log

This is an answer to the general case of "Why am I getting 500 response". Once you know the answer to that question, you can start to debug the specific issue being faced.

  • Thank you. I just wanted to make an update on the issue, because I found the reason for the 500 code. I found the reason for 500 code. Sometimes my conditions were not met and the post request was not transmitted, so a 500 error occurred Aug 2 at 12:45

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.