It seems that the MapDelete expects a single id to be passed, but my situation, I need to pass a pair of ids. I thought passing a JSON object content would work but it doesn't. Having a POST to act as DELETE can work but it has to have a different path.
Here is my code that results in the request matched multiple endpoints.
app.MapPost("/movies/achievements", async (CreateMovieAchievementCommand cmd, ISender sender) =>
{
var id = await sender.Send(cmd);
return TypedResults.Created("/movies/achievements", id);
});
app.MapPost("/movies/achievements", async (RemoveMovieAchievementCommand cmd, ISender sender) =>
{
await sender.Send(cmd);
return TypedResults.Ok();
});
I would like to change last one to either MapDelete or some how make the 2 posts different enough that it would not result in ambiguity (hoping to keep the URLs the same if possible)
RemoveMovieAchievementCommand contains AchievementId and MovieId
You have defined two identical endpoints. Change the one for
RemoveMovieAchievementCommandto be DELETE which would be much more idiomatic in the REST API paradigm (note that explicitFromBodyAttributeis needed):Also usually you need only id for delete so you can do something like:
I would argue that more RESTfull approach would be moving both to the request path:
Also see: