Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST standard for checking if resource exists

What is the REST way to check if resource exists or not? Let say you have some resource called Project. By my understating one of this would be the way :

GET the resource

GET /rest/projects/123

GET /rest/projects/someCriteria

GET /rest/projects/listOfIds

simple but this way the entire object is retrieved if available and we just want to check if it is there. Is there more elegant solution, maybe using HEAD?

like image 619
Mite Mitreski Avatar asked Feb 24 '12 13:02

Mite Mitreski


1 Answers

The REST way is to use whatever the uniform interface allows in your specific architecture. For HTTP the best match is HEAD. If you need information beyond the simple existence of a resource, consider OPTIONS.

like image 166
mpm Avatar answered Sep 25 '22 20:09

mpm