title: REST: Why URI as Data Container?
body: <p>I am supposed to make web services for an app and thought I could do a nice job practicing the good practice. As I found out it's using REST. But there is one thing that makes very little sense in it.</p>
  
  <p><strong>Why use URI to pass any variable?</strong></p>
  
  <p>What we did in our last project is use POST only and pass whatever as raw POST data (which was JSON). That's not very RESTful. But it has some advantages. It was quite simple on the client side - I had a general function that takes URI and data as arguments and then it wraps it up and sends it.</p>
  
  <p>Now, if I used proper REST, I would have to pass some data as part of the URI (user ID, for instance). All the other data (username, email and etc.) would have to go as raw data, like we did, I guess. That means I would have to separate user ID and the other data at some point. That's not so bad but still - why?</p>
  
  <p><strong>EDIT</strong>
  Here is a more detailed example:</p>
  
  <p>Let's say you want to access (GET) and update (POST) user data. You may have a service accessible under <em>/user</em> but what RESTful service would do is accept user's ID as part of the URI (<em>/user/1234</em>). All the other data (name, email and etc) would go to request content (probably as JSON).</p>
  
  <p>What I pose is that it seems useless to make put user id in the URI. If you wanted to update user data - you would send additional data as content anyway. If you wanted to access it - you could use same generic method to request web service.</p>
  
  <p>I know GET gets cached by a browser but I believe you have to cache it manually anyway if you use AJAX (web) or any HTTP client library (other platforms).</p>
  
  <p>From point of scalability - you can always add more services.</p>