This is a follow up question to : Transactions in REST?
How does one implement a REST API that offers full transaction capabilities to it's clients?
For example, if a client wants to create a transaction that will do the following operations:
- create one or more objects.
- update one or more objects.
- delete one or more objects.
While it's a valid requirement for a transaction, it seems to break the REST requirements to use PUT to create, POST to update and DELETE to delete.
My current solution involves handling the entire system as one hierarchical object structure and using the POST operation. For example:
POST /system
{
"Users" : [
{
"ID":"123",
"name":"bob"
// update the user with ID matching 123,
// set his name to "bob"
},
{
"ID":"456",
"delete":"true"
// trigger a delete on user with ID 456
}
],
"Products" : [
{
"name":"foo"
// create a product named "foo" since no ID is provided
},
]
}
So far, this satisfies most REST requirements except for the "delete" flag which isn't really a piece of data.
I'm curious to know if anyone found a better solution.