I try to mock a foreign API for testing purposes. However, when I build the endpoint, I cannot access the data sent via post request.
This is the request, that works totally fine with the original API (created with postman)
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://myEndpointUrl.com/endPoint',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"custAddrZip":"12345",
"custAddrCountry":"de",
"custGender":"m",
"products":["123456"],
"shopDocumentId": "4567890"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-API-Key: AUTHORIZATION_KEY'
),
)
);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
on the endpoint side there is currently just:
var_dump($_POST);
var_dump(file_get_contents("php://input"));
which returns
array(0) {
}
string(0) ""
where I expect to get the Json string instead.
How can I access the data sent in POST?