I want to have a PHP script that I post to with Postman. In the body, I have a simple JSON string and I want to read that string in my PHP script. I currently have a local XAMPP 7.3.10 server setup.
So in Postman, I Post to http://localhost/upload.php
and then in my PHP script, I echo and var_dump the $Post
. But I get an empty array back in the response?
I'm new to PHP so I'm not really sure if this is the way to do it?
JSON body
{
"Test": "testValue"
}
Php
<?php
echo "POST: ";
print_r($_POST);
var_dump($_POST);
if (!empty($_POST)) {
echo "POST: ";
print_r($_POST);
var_dump($_POST);
echo "FILES: ";
print_r($_FILES);
var_dump($_FILES);
} else {
echo "The post array is empty.";
}
Response in Postman
POST: Array
(
)
array(0) {
}
The post array is empty.