Reputation: 341
I have a collection of users. Each user have phone.
In application user can check if a user exists in application by sending a phone number.
How to do it in more restful way?
Upvotes: 0
Views: 43
Reputation:
GET /users?phoneNumber=1234
would return a collection of users that have the phone number `1234.
Edit:
Since you are not interested in the specific user but only in the fact that a user having the given phone number exists, the REST Resource would be this fact.
GET /user-phone-number-existence/1234
The name user-phone-number-existence
is just a quick idea, you can change it, of course. The important point is that it is a noun, not a verb.
The response code would be 204 No Content
if a user having the phone number exists. If no such user exists, a 404 Not Found
would be the response code.
I see no necessity to include a body with the response, everything can be communicated using HTTP status codes.
Upvotes: 1