I have a web application in which there are many pages with the URL of the form / object _type / object_id / that show this information about objects. I also have a RESTful API returning a JSON / XML representation of my objects (in / api / object_type / object_id /). (My objects are laws and bills, but I think this question is pretty general).
From time to time, I find that two or more of my objects are actually duplicated and describe the same object in the real world. Let's say that they were / Bill / 111 / and / Bill / 222 /. Behind the scenes, I am combining 2 objects, leaving 1 object (say, / Bill / 111 /) with all the information, and the other is โemptyโ with only a link to another.
My question is: how can I specify merging in a web application and in an API? I do not want / Bill / 222 / to return 404, because I can have external links pointing to it, and I do not want them to be broken. Should I use 301 moved permanently? Should I return a normal page (with a status of 200), explaining that this resource was detected as a duplicate with a link to the merged? How should I work with this in the API? for example, should I list 222 in the Bills index?
source share