magento2.3 controller won't handle post methodMagento 2.3 upgrade breaks HTTP POST requests to custom module endpointWhere in a custom module can you declare / consolidate all of your custom functionsMagento2 Override Contact Post ControllerMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Compile: Extra parameters passed to parent construct: $contextMy Controller Won't Work!Magento 2.3 Can't view module's front end page output?Magento 2 plugin change price of products that have a custom attribute withHow to create AJAX action for POST requests in Magento 2.3?jquery Issue with magento2.3 backendMagento 2.3 - Get child categories of parent

How should I interpret a promising preprint that was never published in a peer-reviewed journal?

What is the origin of "Wonder begets wisdom?"

Inside Out and Back to Front

A Real World Example for Divide and Conquer Method

Project Euler # 25 The 1000 digit Fibonacci index

How to tell readers that I know my story is factually incorrect?

What is the simplest instruction set that has a C++/C compiler to write an emulator for?

Is it ethical to tell my teaching assistant that I like them?

Manager is asking me to eat breakfast from now on

Will copper pour help on my single-layer PCB?

Father as an heir

A bicolour masyu

Why are flying carpets banned while flying brooms are not?

"This used to be my phone number"

The most secure way to handle someone forgetting to verify their account?

Does unblocking power bar outlets through short extension cords increase fire risk?

Why are there few or no black super GMs?

How far off did Apollo 11 land?

Why should fork() have been designed to return a file descriptor?

Why is there an extra "t" in Lemmatization?

Last-minute canceled work-trip means I'll lose thousands of dollars on planned vacation

Three Subway Escalators

Why would word of Princess Leia's capture generate sympathy for the Rebellion in the Senate?

Does a hash function have a Upper bound on input length?



magento2.3 controller won't handle post method


Magento 2.3 upgrade breaks HTTP POST requests to custom module endpointWhere in a custom module can you declare / consolidate all of your custom functionsMagento2 Override Contact Post ControllerMagento 2.1: Do we need to do anything special for the controll action to accept HTTP Post with Json Payload?Compile: Extra parameters passed to parent construct: $contextMy Controller Won't Work!Magento 2.3 Can't view module's front end page output?Magento 2 plugin change price of products that have a custom attribute withHow to create AJAX action for POST requests in Magento 2.3?jquery Issue with magento2.3 backendMagento 2.3 - Get child categories of parent






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















This is something I used to be able to do in 2.2, but in 2.3 I can't.



A simple controller to handle a POST method, and only receive and send application/json content type.



It works for GET/PUT methods, but if POST, it will render home page (html).



<?php

namespace <vendor><module>ControllerApi;

class MyApi extends MagentoFrameworkAppActionAction


public function execute()

$result = $this->createResultJson();

$result->setData([
'message' => 'All Good.'
]);

$result->setHttpResponseCode(200);

return $result;



/**
* @return MagentoFrameworkControllerResultInterface









share|improve this question




























    1















    This is something I used to be able to do in 2.2, but in 2.3 I can't.



    A simple controller to handle a POST method, and only receive and send application/json content type.



    It works for GET/PUT methods, but if POST, it will render home page (html).



    <?php

    namespace <vendor><module>ControllerApi;

    class MyApi extends MagentoFrameworkAppActionAction


    public function execute()

    $result = $this->createResultJson();

    $result->setData([
    'message' => 'All Good.'
    ]);

    $result->setHttpResponseCode(200);

    return $result;



    /**
    * @return MagentoFrameworkControllerResultInterface









    share|improve this question
























      1












      1








      1


      0






      This is something I used to be able to do in 2.2, but in 2.3 I can't.



      A simple controller to handle a POST method, and only receive and send application/json content type.



      It works for GET/PUT methods, but if POST, it will render home page (html).



      <?php

      namespace <vendor><module>ControllerApi;

      class MyApi extends MagentoFrameworkAppActionAction


      public function execute()

      $result = $this->createResultJson();

      $result->setData([
      'message' => 'All Good.'
      ]);

      $result->setHttpResponseCode(200);

      return $result;



      /**
      * @return MagentoFrameworkControllerResultInterface









      share|improve this question














      This is something I used to be able to do in 2.2, but in 2.3 I can't.



      A simple controller to handle a POST method, and only receive and send application/json content type.



      It works for GET/PUT methods, but if POST, it will render home page (html).



      <?php

      namespace <vendor><module>ControllerApi;

      class MyApi extends MagentoFrameworkAppActionAction


      public function execute()

      $result = $this->createResultJson();

      $result->setData([
      'message' => 'All Good.'
      ]);

      $result->setHttpResponseCode(200);

      return $result;



      /**
      * @return MagentoFrameworkControllerResultInterface






      controllers magento2.3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 13 '18 at 18:49









      Mac A.Mac A.

      5711 bronze badges




      5711 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          0














          This solves the problem, but after that your module will not work on Magento 2.2 and earlier https://magento.stackexchange.com/a/255082/75860






          share|improve this answer






























            0














            To handle the POST method in your controller class, you have to implement the MagentoFrameworkAppActionHttpPostActionInterface interface:



            <?php

            namespace VendorModuleControllerApi;

            use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;

            class MyApi extends MagentoFrameworkAppActionAction implements HttpPostActionInterface

            public function execute()

            // ...




            You can check how the Login controller does it:




            vendor/magento/module-customer/Controller/Ajax/Login.php




            Also, you should send the Headers correctly, for example:



            "Content-Type": "application/json",
            "X-Requested-With": "XMLHttpRequest"





            share|improve this answer



























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f253585%2fmagento2-3-controller-wont-handle-post-method%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              This solves the problem, but after that your module will not work on Magento 2.2 and earlier https://magento.stackexchange.com/a/255082/75860






              share|improve this answer



























                0














                This solves the problem, but after that your module will not work on Magento 2.2 and earlier https://magento.stackexchange.com/a/255082/75860






                share|improve this answer

























                  0












                  0








                  0







                  This solves the problem, but after that your module will not work on Magento 2.2 and earlier https://magento.stackexchange.com/a/255082/75860






                  share|improve this answer













                  This solves the problem, but after that your module will not work on Magento 2.2 and earlier https://magento.stackexchange.com/a/255082/75860







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 14 at 8:29









                  Laurynas KanaporisLaurynas Kanaporis

                  11 bronze badge




                  11 bronze badge























                      0














                      To handle the POST method in your controller class, you have to implement the MagentoFrameworkAppActionHttpPostActionInterface interface:



                      <?php

                      namespace VendorModuleControllerApi;

                      use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;

                      class MyApi extends MagentoFrameworkAppActionAction implements HttpPostActionInterface

                      public function execute()

                      // ...




                      You can check how the Login controller does it:




                      vendor/magento/module-customer/Controller/Ajax/Login.php




                      Also, you should send the Headers correctly, for example:



                      "Content-Type": "application/json",
                      "X-Requested-With": "XMLHttpRequest"





                      share|improve this answer





























                        0














                        To handle the POST method in your controller class, you have to implement the MagentoFrameworkAppActionHttpPostActionInterface interface:



                        <?php

                        namespace VendorModuleControllerApi;

                        use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;

                        class MyApi extends MagentoFrameworkAppActionAction implements HttpPostActionInterface

                        public function execute()

                        // ...




                        You can check how the Login controller does it:




                        vendor/magento/module-customer/Controller/Ajax/Login.php




                        Also, you should send the Headers correctly, for example:



                        "Content-Type": "application/json",
                        "X-Requested-With": "XMLHttpRequest"





                        share|improve this answer



























                          0












                          0








                          0







                          To handle the POST method in your controller class, you have to implement the MagentoFrameworkAppActionHttpPostActionInterface interface:



                          <?php

                          namespace VendorModuleControllerApi;

                          use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;

                          class MyApi extends MagentoFrameworkAppActionAction implements HttpPostActionInterface

                          public function execute()

                          // ...




                          You can check how the Login controller does it:




                          vendor/magento/module-customer/Controller/Ajax/Login.php




                          Also, you should send the Headers correctly, for example:



                          "Content-Type": "application/json",
                          "X-Requested-With": "XMLHttpRequest"





                          share|improve this answer















                          To handle the POST method in your controller class, you have to implement the MagentoFrameworkAppActionHttpPostActionInterface interface:



                          <?php

                          namespace VendorModuleControllerApi;

                          use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;

                          class MyApi extends MagentoFrameworkAppActionAction implements HttpPostActionInterface

                          public function execute()

                          // ...




                          You can check how the Login controller does it:




                          vendor/magento/module-customer/Controller/Ajax/Login.php




                          Also, you should send the Headers correctly, for example:



                          "Content-Type": "application/json",
                          "X-Requested-With": "XMLHttpRequest"






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 28 at 18:10

























                          answered Feb 28 at 17:58









                          Andres Rojas OrozcoAndres Rojas Orozco

                          1701 silver badge11 bronze badges




                          1701 silver badge11 bronze badges



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f253585%2fmagento2-3-controller-wont-handle-post-method%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                              Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                              Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림