I'm trying to send a form from a Java Spring Application to Magento.
What I'm doing in Java is just creating an standard form and on action I wrote Magento's controller path.
Like this:
http://ip/application/send/application
When I post the form, I get redirected to just http://ip
and a message showing : Invalid Form Key. Please refresh the page.
This is my controller on Magento:
public function execute()
{ $post = $this->getRequest()->getPostValue();
$resultPage = $this->_resultPageFactory->create();
$block = $resultPage->getLayout()->getBlock('application_send');
$block->setData('post',$post);
return $resultPage;
}
And my layout.xml for the controller:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Vendor\Application\Block\Main" name="application_send" template="Vendor_Application::application.phtml"/>
</referenceContainer>
</body>
</page>
Do I need to return a token on controller? or do I need to send a token from Java Form?
Greetings!