Reputation: 2255
When creating a new ASP.net WebAPi Rest controller, visual studio adds a DELETE action like this
// DELETE: api/foo/5
public void Delete(int id)
{
}
And I can successfully call that endpoint
But the 'id' in my system are string hashes so I need to pass the 'id' as a string not an int e.g
// DELETE: api/foo/58c75babbf61cda99c84af8b
public void Delete(string id)
{
}
But when I change this, the DELETE action no longer is called and I get the error "No HTTP resource was found that matches the request URI "
Any ideas why? and how do get around this?
Upvotes: 1
Views: 3405
Reputation: 4369
You can specify the route template yourself, and in it, specify that id is a guid:
[HttpDelete, Route("api/foo/{id}")]
public void Delete(string id)
{
}
Upvotes: 5