I am sending this request from Insomnia (a PostMan like software). I am sending a simple XML file
<?xml version='1.0' encoding='UTF-8'?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
And on Header i only have Content-Type: application/xml I am sending this to an php file which contains this code:
$xml = file_get_contents('php://input');
echo "<pre>";
print_r(htmlspecialchars($xml));
echo "</pre>";
Which is outputting an empty string. On my local server it's outputting the xml file how it should be.
My settings on my paid server are:
My Insomnia screen looks like this:
The output comes from this code:
echo "<pre>";
print_r($_POST);
echo "</pre>";
Outputs the empty array and:
if (!empty($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/xml') {
echo "application/xml";
}
Outputs "application/xml".
Answer: it turns out in my case i should have wrote the address with HTTPS instead of HTTP.