Suppose I have two resoureces: carts and items. Items can be nested inside cart or can be not this way:
/carts/32658/items/screwdriver
/items/screwdriver
Does the same item in cart and not in cart are different resources in REST conventions?
Suppose I have two resoureces: carts and items. Items can be nested inside cart or can be not this way:
/carts/32658/items/screwdriver
/items/screwdriver
Does the same item in cart and not in cart are different resources in REST conventions?
As other answers and comments have suggested there is no REST violation when having multiple URI to one resource and different sources and SO answers say so.
Each resource in a service suite will have at least one URI identifying it.
But I would rethink if you allow all HTTP methods on the second resource link. Given /carts/32658/items/screwdriver it might not good to allow PUT, because clients might think they will just change the screwdriver in cart #32658 and not the global screwdiver entity.
If you are talking about same screwdriver then they are same resources. One resource may have several URL's. In that case one of them is chosen to be official URL and is called Canonical URL. Official screwdriver URL might be /items/screwdriver where client might get full info about it.
carts/32658/items/ resource I shold have link to /items/screwdriver resource with full info about item, and /carts/32658/items/screwdriver url shoud be disabled?/carts/32658/items/screwdriver. /carts/32658/items/screwdriver and /items/screwdriver are all URL's of the same resource. They may give you the same information(or may not) and same representation(one xml and another json). They all talk about the same thing(resource) - screwdriver. If you want to mark some URL as official you may add Content- Location header in /carts/32658/items/screwdriver pointing to canonical /items/screwdriver. Thus you are saying that official URL of screwdriver is here /items/screwdriver.