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;
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
add a comment |
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
add a comment |
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
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
controllers magento2.3
asked Dec 13 '18 at 18:49
Mac A.Mac A.
5711 bronze badges
5711 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
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"
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Jan 14 at 8:29
Laurynas KanaporisLaurynas Kanaporis
11 bronze badge
11 bronze badge
add a comment |
add a comment |
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"
add a comment |
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"
add a comment |
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"
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"
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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