Complex transactions in REST?

This is the next question: Transactions in REST?

How to implement a REST API that offers all the transaction features for it?

For example, if a client wants to create a transaction that will perform the following operations:

  • create one or more objects.
  • update one or more objects.
  • delete one or more objects.

While this is a valid requirement for a transaction, it seems to violate the REST requirements for using PUT to create, POST to update, and DELETE to delete.

My current solution involves processing the entire system as one hierarchical structure of an object and using the POST operation. For instance:

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, it satisfies most REST requirements, with the exception of the β€œdelete” flag, which is not really part of the data.

I am curious to see if anyone has found a better solution.

+4
source share
1 answer

Agree with Jan that you need to process on serveride.but down side the code is poorly supported. Yes, my experience with Restful applications shows that sticking to the PUT and DELETE verbs in RESTFul Architecture is quite difficult, since support for different versions of the browser is far limited for them.

0
source

All Articles