Reputation: 3735
I have a simple question, but I can not seem to find the answer somewhere on the internet.
When using path parameters in a REST API, are the following methods on different endpoints or will it conflict?
[HttpGet("{stringId}")]
public IActionResult GetObjectByStringId(string stringId) {
}
[HttpGet("{integerId}")]
public IActionResult GetObjectByIntegerId(int integerId) {
}
Upvotes: 0
Views: 198
Reputation: 541
When you hit one of your above mentioned endpoint, it will give error i.e. "The request matched multiple endpoints." You can solve this by specifying the type like below
[HttpGet("{integerId:int}")]
public IActionResult GetObjectByIntegerId(int integerId) {
}
Upvotes: 1