There seems to be an issue with the API handling JSON input. This is my API (Delete function)
function doDeleteCustomer() {
global $db;
if(isParamSet(array('id'))) {
if(isParamAvailable(array('id'))) {
$customerId = $_REQUEST['id'];
$sql = "DELETE FROM customers WHERE ID=:customerid";
$stmt = $db->prepare($sql);
$stmt->execute(
array(
':customerid' => $customerId
)
);
if($stmt->rowCount() > 0) {
$response = array();
$response["error"] = false;
$response["status"] = 200;
$response["data"] = array();
$response["message"] = "Successfully removed customer!";
} else {
$response = array();
$response["error"] = true;
$response["status"] = 400;
$response["data"] = array();
$response["message"] = "Unable to remove customer!";
}
return json_encode($response);
}
}
}
When I test it in Postman everything works fine, but I have provide the information in x-www-form-urlencoded.
But when I want to give the input by raw JSON data I get a message that the required id field is missing...What am I doing wrong?