Postman DELETE requests result in 404

I am currently working on the section titled Building RESTful Services with 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:
public IHttpActionResult DeleteCustomer(int id)
var customerInDb = _context.Customers.SingleOrDefault(x => x.Id == id);

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


        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

Anyone have any ideas of what could be going on?

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?


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.

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

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

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.

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

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.

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)?

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

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

Can you update your annotation like this.


Can you show us your RoutesConfig.cs file please?

This is mine

using System.Web.Mvc;
using System.Web.Routing;

namespace Vidly
   public class RouteConfig
      public static void RegisterRoutes(RouteCollection routes)

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

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

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

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.

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