# Postman DELETE requests result in 404

**URL:** <https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050>\
**Category:** ASP.NET MVC\
**Created:** [June 13, 2022, 8:57pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050 "2022-06-13T20:57:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [June 13, 2022, 8:57pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/1 "2022-06-13T20:57:51Z")

</div>

I am currently working on the section titled Building RESTful Services with [ASP.NET](http://ASP.NET) Web API. I  
am trying to delete customers, however every attempt that I have made has resulted in a 404 error. I looked at the code on github but could not figure out why the DELETE requests are failing.

This is a copy of my delete method:  
[HttpDelete]  
public IHttpActionResult DeleteCustomer(int id)  
{  
var customerInDb = \_context.Customers.SingleOrDefault(x =\> x.Id == id);

```
        if (customerInDb == null)
            return NotFound();

        _context.Customers.Remove(customerInDb);
        _context.SaveChanges();

        return Ok();
    }

```

My web Api configuration expects a route of the form: “api/{controller}/{id}”

In result, in order to delete a customer, I send a DELETE request to: [https://localhost:44313/api/customers/0](https://localhost:44313/api/customers/0)

Anyone have any ideas of what could be going on?

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [June 13, 2022, 9:06pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/2 "2022-06-13T21:06:59Z")

</div>

Hi,  
At first sight it seems correct to me.  
Now did you try putting a breakpoint and send a request to make sure the action is getting called?  
Regards.

---

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [June 14, 2022, 12:44pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/3 "2022-06-14T12:44:18Z")

</div>

Hello,

Yes, I put a break point on the line where customerInDb was created. When I sent a DELETE request, the break point was never reached. I suspect that the computer does not know to call the delete method inside of the API, but I do not know what else it would try to call.

---

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [June 14, 2022, 2:00pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/4 "2022-06-14T14:00:20Z")

</div>

I noticed that the id of all of my customers was 0 and I found this to be helpful: [Vidly Customers API returns customers with id=0](https://forum.codewithmosh.com/t/vidly-customers-api-returns-customers-with-id-0/4652)

My DELETE requests still do not work, but I just thought that I should mention this.

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [June 14, 2022, 3:14pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/5 "2022-06-14T15:14:08Z")

</div>

This is exactly what I expected.  
What I asked you to do is to make sure you call your endpoint properly.  
This happened to me also.  
Check everything such as id, typo, routing configuration.

Check the URL of the request sent from the Browser.  
Something makes the URL malformed and thus the endpoint is never called.

PS : How are you calling the endpoint?  
In-App? Swagger ? Postman ? Other ?  
The problem lies likely there.

---

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [June 14, 2022, 4:29pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/6 "2022-06-14T16:29:11Z")

</div>

I am using the Postman app on Windows. My request looks like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/e/e53cf1b1cb3cb46ffa96523e498ef8006e637fc0.png)

Also I have been able to make GET requests without a problem. For some reason it just seem like my computer cannot find the delete method inside of the API.

---

<div class="post-metadata">

**Author:** ![sufian.babri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sufian.babri/32/1028_2.png) [@sufian.babri](https://forum.codewithmosh.com/u/sufian.babri)\
**Post date:** [June 15, 2022, 1:47am UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/7 "2022-06-15T01:47:10Z")

</div>

Does changing the URL to lower case (`/api/customers`) fix it (in Postman you are using an uppercase C)?

Have you checked in your code that you have set up the endpoint properly (correct endpoint name, method type to delete)?

---

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [June 15, 2022, 12:39pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/8 "2022-06-15T12:39:51Z")

</div>

Thanks, I did try that and unfortunately it did not work. Also, in my recent attempts to fix things I have caused my server to stop working, so I think I am just going to restart.

@sufian.babri, @UniqueNospaceShort Thank you for trying to help me out

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [June 24, 2022, 6:23am UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/9 "2022-06-24T06:23:05Z")

</div>

On my API it is case insensitive. That said, it’s sure a thing to try.

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [June 24, 2022, 6:36am UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/10 "2022-06-24T06:36:05Z")

</div>

Can you update your annotation like this.

`[HttpDelete("{id}")]`

Can you show us your `RoutesConfig.cs` file please?

This is mine

```nohighlight
using System.Web.Mvc;
using System.Web.Routing;

namespace Vidly
{
   public class RouteConfig
   {
      public static void RegisterRoutes(RouteCollection routes)
      {
         routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

         // The important line is this one. Then you can use attribute routing.
         // [Route("/api/Customers/{id}")]
         routes.MapMvcAttributeRoutes();

         //routes.MapRoute("MoviesByReleaseDate", 
         // "movies/released/{year}/{month}", 
         // new { controller="Movies", action="ByReleaseDate"}, 
         // new { year= @"\d{4}", month= @"\d{2}"});

         routes.MapRoute(
             name: "Default",
             url: "{controller}/{action}/{id}",
             defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
         );
      }
   }
}

```

---

<div class="post-metadata">

**Author:** ![sKut](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@sKut](https://forum.codewithmosh.com/u/sKut)\
**Post date:** [July 1, 2022, 2:14pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/11 "2022-07-01T14:14:11Z")

</div>

Sorry to take so long to respond, and thanks for sticking with me. I ended up getting rid of the project entirely because there were too many problems with my project. I am now going through the angular4 course and might get back to this some other day. Thanks again though.

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [July 4, 2022, 8:40pm UTC](https://forum.codewithmosh.com/t/postman-delete-requests-result-in-404/13050/12 "2022-07-04T20:40:24Z")

</div>

That’s a pity.  
Anyways good luck on your Angular course.
