title: RESTful optimistic locking in Restangular
body: <p>I have restful api where the client first loads a collection of entities from a resource</p>
  
  <pre><code>GET http://wherever/api/tasks
  </code></pre>
  
  <p>and then wants to delete a particular task from that collection</p>
  
  <pre><code>DELETE http://wherever/api/tasks/42
  </code></pre>
  
  <p>To protect against inadvertant deletion of concurrent updates, the delete should only succeed if the entity has not been modified since it has been loaded. We'd like to solve this using optimistic locking.</p>
  
  <p>How do I pass the current / expected version through the REST API? </p>
  
  <p><a href="https://www.committedcoder.com/restangular-and-etags-pt1.html" rel="nofollow">Apparently</a>, the RESTful best practice is to pass the version through ETags (presumably to leverage synergies with HTTP caching), but how can I do this if the entity is loaded from a different URL than it will be deleted from? (I'd like to avoid issuing a GET for each individual task, as finding the collection of tasks is as expensive as finding their state)</p>
  
  <p>We are using Restangular on the client side, and Jersey on the server side.</p>