Reputation: 49077
I am creating a web service and I follow the RESTful way of doing it. So I have resources such as Person, Ticket etc. I have all the normal CRUD operations, some finders and so on. I also want to expose service methods such as randomTicket()
which is defined in a RandomTicketGenerator
class. I am unsure if it is bad to expose service methods in a REST API like this? For instance the path above would be /randomTicket
and only answer on GET requests.
Upvotes: 0
Views: 310
Reputation: 1068
/ticket/random
is a bit confusing as it could be interpreted as meaning 'give me the ticket with ID=random'
How about returning a single item via: GET /ticket?random=true
Or a list of items via: GET /tickets?random=true&maxItems=1
Upvotes: 1