In my current maintenance project, there is REST API resource URL like this:
/sites/<site id or site code>/buildings/<building id or building code>
In this endpoint URL, there are two parameters,
<site id or site code>
<building id or building code>
As the name indicates, these two parameters are ambiguous, say the value of the first parameter can be either site id or site code, the value of the second parameter can be either building id or building code.
However, implicitly it means,
For instance, there is a building with 1 as building id and rake as building code, and it is located in the site with 5 as the site id and SF as the site code, then the following endpoint URL should retrieve the same result:
However, there is a hint in the HTTP header indicating the given value of the path parameter is code or ID. Even though, the implementation of such resource endpoint contains lots of
if conditions due to the ambiguity. However, from the end-user's aspect, this seems to be handy
My question is whether such endpoint design is a good practice or a typical bad practice?