DELETE android with Webservice URL does not work

1

I'm having a boring problem that I still can not solve and involves PHP and Android (more PHP actually).

I am accessing a WebService in PHP that performs an operation according to each method requested by Android (for example: POST makes insert, PUT does update, etc.), all POST, PUT e GET methods are running quietly , but DELETE does not.

I'll show the snippet of code in PHP and try to explain:

else if ($metodoHttp == 'DELETE') {
    $stmt = $conn->prepare("DELETE FROM hotel_db.Hotel WHERE id=?");
    $segments = explode("/", $_SERVER["REQUEST_URI"]);
    $id = $segments[count($segments)-1];
    $stmt->bind_param("i", $id);
    $stmt->execute();
    $stmt->close();
    $jsonRetorno = array("id"=>$id);
    echo json_encode($jsonRetorno);
}

In this code, the page in PHP checks if the method is DELETE and if it is, takes the parameter that comes along with the URL after the / deletes the record in the database with that id, and returns the deleted registry id.

In android I asked to write in Log the URL that was being sent to see if it was going right and it is going like this:

link

I do not know if there is any error in the code in PHP (in the way it retrieves the id in the URL) because in the android everything seems to be right.

    
asked by anonymous 14.03.2016 / 15:27

0 answers