I have a REST web service in API Tools for CRUD of a database table (DB2 for i) where the (unique) key is an identity column called “order_id”. The route looks like this:
'route' => '/sleep-order-header[/:order_id]',
Both the route identifier and entity identifier are 'order_id`
So if I want to fetch a single record, I’d use the URL “…/sleep-order-header/123” (to get order_id=123.
The problem is that, when creating the record (via POST), I don’t know the value of the key that will be created. So I have to call it with just ."…/sleep-order-header" (not passing the order_id). I also have to enable POST for Collections. Then it will call the
create function in my SleepOrderHeaderResource. The problem is that it returns a collection of all the records in the table. I want it to return only the record last added I tried just retrieving the new record (or just the order_id of the record just created) and returning that in the
create() function, but I still get the whole table.
Question: How can I force the POST to return just the one record just created?