When you say that you want to implement this function in a "single transaction", I assume that you have already determined that you should combine the creation of new invoices and the removal of the old into a single API call; which is the right approach. With web services, you want to reduce chatter, and there are probably some business logic on how this feature will generate new accounts and delete old ones. Therefore, I assume that when you ask how to do this in RESTful, you are wondering which HTTP verb to use (i.e. GET, POST, PUT or DELETE) for this new API method. Typically, these verbs display CRUD operations as follows:
- Create → POST
- Reading → GET
- Update → PUT
- Delete → DELETE
So which verb to use when your function creates and removes entries. The general rule with the REST API is if there is no clear mapping to CRUD, then use POST if there is a change in server status and GET if you simply return information that does not change the server state. So in this case, I would go with POST.
If you are looking for additional architectural recommendations, please be more specific about what you are looking for and I will try to help.
Kevin junghans
source share