# DELETE method with parameter - 404 Not found \[SOLVED\]

**URL:** <https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008>\
**Category:** Questions\
**Created:** [November 13, 2017, 2:27pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008 "2017-11-13T14:27:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sh13](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/sh13/32/533_2.png) [@sh13](https://discourse.slimframework.com/u/sh13)\
**Post date:** [November 13, 2017, 2:27pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/1 "2017-11-13T14:27:32Z")

</div>

Hi there, I am currently in the process of learning how to buid my own REST API using the Slim v3. I found several tutorials and was able to build multiple routes to send GET and POST requests to my MySQL database. Next up for me is a delete request, but it doesn’t work.

**This is my code:**

```
$app->delete('/usuario/[{correo}]', function ($request, $response, $args) {
  $sth = $this->db->prepare("DELETE FROM usuarios WHERE email=:correo");
  $sth->bindParam("correo", $args['correo']);
  $sth->execute();
  $todos = $sth->fetchAll();
  return $this->response->withJson($todos);
});

```

I am testing it in Postman and I always have the same problem: _404 Not found_. I can not understand it because I think the url is correct (`http://localhost:8080/usuario/bbb@bbb.es`).

 ![Sin título-1](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/1X/e813bfe61815347c921fa32e6739b5348e61245f.jpg)

Can anyone help me?

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 13, 2017, 3:32pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/2 "2017-11-13T15:32:52Z")

</div>

That route works for me. (I didn’t setup a DB to test the database code.) I suspect it is something else in your environment that is causing the 404… Something in your `.htaccess`, other webserver config, or something within Postman.

App:

```php
<?php

require __DIR__. '/../vendor/autoload.php';

// Instantiate the app
$settings = require __DIR__. '/../src/settings.php';
$app = new \Slim\App($settings);

$app->delete('/usuario/[{correo}]', function ($request, $response, $args) {
    return $this->response->withJson($args['correo']);
});

// Run app
$app->run();

```

Request:

```auto
## Request
curl -X "DELETE" "http://slim-skeleton.localhost:8080/usuario/bbb@bbb.es" \
     -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
     -H 'Accept: application/json'

```

Response:

```auto
HTTP/1.1 200 OK
Server: Apache
Content-Type: application/json;charset=utf-8
X-Powered-By: PHP/7.0.14
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Date: Mon, 13 Nov 2017 15:27:29 GMT
X-Frame-Options: SAMEORIGIN
Keep-Alive: timeout=5, max=100
Content-Length: 12
Connection: Keep-Alive

"bbb@bbb.es"

```

---

<div class="post-metadata">

**Author:** ![sh13](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/sh13/32/533_2.png) [@sh13](https://discourse.slimframework.com/u/sh13)\
**Post date:** [November 13, 2017, 4:06pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/3 "2017-11-13T16:06:15Z")

</div>

> [@tflight](#):
>
> That route works for me. I suspect it is something else in your environment that is causing the 404…

That is my problem I do not know why it does not work, because if I use the POST method, it works.

```
$app->post('/eliminar', function ($request, $response) {
  $input = $request->getParsedBody();
  $sql = "DELETE FROM usuarios WHERE email=:correo";
  $sth = $this->db->prepare($sql);
  $sth->bindParam("correo", $input['correo']);
  $sth->execute();
  $input['id'] = $this->db->lastInsertId();
  return $this->response->withJson($input);
});

```

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 13, 2017, 4:26pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/4 "2017-11-13T16:26:30Z")

</div>

We seem to know it isn’t working because you are not getting to that route/action. Which webserver are you using? How is it configured? Have you tried the route from curl or another client?

---

<div class="post-metadata">

**Author:** ![sh13](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/sh13/32/533_2.png) [@sh13](https://discourse.slimframework.com/u/sh13)\
**Post date:** [November 13, 2017, 4:40pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/5 "2017-11-13T16:40:16Z")

</div>

> [@tflight](#):
>
> Which webserver are you using?

I am using XAMPP v7.1.6

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [November 13, 2017, 6:04pm UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/6 "2017-11-13T18:04:33Z")

</div>

Okay, so you are using Apache…

> [@tflight](#):
>
> How is it configured? Have you tried the route from curl or another client?

---

<div class="post-metadata">

**Author:** ![sh13](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/sh13/32/533_2.png) [@sh13](https://discourse.slimframework.com/u/sh13)\
**Post date:** [November 15, 2017, 10:15am UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/7 "2017-11-15T10:15:49Z")

</div>

I have already found the problem.

You can not send dots as a character in the route URL, so you test `http://localhost:8080/usuario/bbb@bbbdotes` it will work fine.

Another way, you can send the email address in the body not in the url

`{"email":"bbb@bbb.es"}`

and then I can deal with it like POST route to fetch the email address as I did it before:

```
$app->post('/usuario, function ($request, $response) {
  $input = $request->getParsedBody();
  $sql = "DELETE FROM usuarios WHERE email=:correo";
  $sth = $this->db->prepare($sql);
  $sth->bindParam("correo", $input['correo']);
  $sth->execute();
  $input['id'] = $this->db->lastInsertId();
  return $this->response->withJson($input);
});

```

Thanks @tflight for your help.

---

<div class="post-metadata">

**Author:** ![marcelloh](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/marcelloh/32/404_2.png) [@marcelloh](https://discourse.slimframework.com/u/marcelloh)\
**Post date:** [November 16, 2017, 8:20am UTC](https://discourse.slimframework.com/t/delete-method-with-parameter-404-not-found-solved/2008/8 "2017-11-16T08:20:55Z")

</div>

Perhaps describe that problem a bit more, and the solution you have for it, to teach future readers 🙂
