Basically I have a /orders resource and I want users to be able to do a search for orders based on different criteria.
Let say order has three columns: orderNum, orderDate, and customerName
Now, if a user wants to find all orders with order numbers like ‘manual’, I would do a query like
SELECT * FROM orders WHERE orderNum LIKE '%manual%';
and do not worry I used parametrized statements. I was thinking I could add a form parameter if I am accepting x-www-form-urlencoded in the body indicating whether the user wants to search by orderNum, orderDAte, or customerName, but this is starting to feel like REST-RPC. I would prefer to do it in a more RESTful manner. Any ideas?
Found this question that was relevant. It is basically the same question. I will rely on SQL errors if a request is made to search for objects based on non-existent properties, and then inform the client, providing a list of possible searchable properties.
RESTful URL design for search