We have to implement the punchout concept in magento2.
There is a 3rd party system they will send data using the cXML format to Magento 2 endpoint. We need to fetch that data in the Magento2 & need to process & need to return the data in the form of cXML format.
For this, we have implemented the vie/api/punchout controller concept instead of REST APIs. which is working when we use the PUT method but it is not working for the POST method.
Note: It should be work for the POST method. When we use POST method our controller is not triggering can anyone help me on this issue.
I have followed the below approaches in the controller but those are working for the PUT method, not for the POST method as per the client request, it should work for the POST method.
$postData = $this->getRequest()->getContent();
$opts = array('http' => array( 'method' => 'POST' ) ); $context = stream_context_create($opts); $x=file_get_contents("php://input", false, $context);> echo $x;
$rawData = file_get_contents("php://input"); echo $rawData;
Steps to verify:
Create on the custom controller in your custom module ex: vie/api/punchout
Open postman app
Keep sample XML data in the postman app at body and type is XML format which I have mentioned above.
Try to fetch the data using the POST method in the controller