Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECommerce Sample Payments API has conflicting delete routes #66

Open
BradKnowles opened this issue Aug 4, 2021 · 1 comment
Open

ECommerce Sample Payments API has conflicting delete routes #66

BradKnowles opened this issue Aug 4, 2021 · 1 comment

Comments

@BradKnowles
Copy link
Contributor

When attempting to execute action DiscardPayment, this error message is returned:

{
    "StatusCode": 500,
    "Error": "The request matched multiple endpoints. Matches: \r\n\r\nPayments.Api.Controllers.PaymentsController.DiscardPayment (Payments.Api)\r\nPayments.Api.Controllers.PaymentsController.TimeoutPayment (Payments.Api)"
}

Both actions are decorated with the same [HttpDelete("{id}")] attribute and ASP.NET doesn't know which to choose.

[HttpDelete("{id}")]
public async Task<IActionResult> DiscardPayment(Guid id, [FromBody] DiscardPaymentRequest request)
{
Guard.Against.Null(request, nameof(request));
var command = Payments.DiscardingPayment.DiscardPayment.Create(
id,
request.DiscardReason
);
await commandBus.Send(command);
return Ok();
}
[HttpDelete("{id}")]
public async Task<IActionResult> TimeoutPayment(Guid id, [FromBody] TimeOutPaymentRequest request)
{
Guard.Against.Null(request, nameof(request));
var command = TimeOutPayment.Create(
id,
request.TimedOutAt
);
await commandBus.Send(command);
return Ok();
}

@BradKnowles
Copy link
Contributor Author

I didn't attempt a PR on this one as I don't know how you'd like to solve it. Do you want DiscardPayment and TimeoutPayment to be part of the route? Or are you looking for a more elegant solution where ASP.NET figures out which action to execute based on the request body?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant