title: RESTful API: Should I send URI parts in the response body? And how about Updating them?
body: <p>I am building a <code>RESTful</code> API and I am not sure whether it is a problem (and violation of REST) to send information that is the same as <code>URI</code> parts in the response <code>body</code> or not.<br></p>
  
  <h2>Current Situation</h2>
  
  <p>An <code>GET</code> <code>/element/$ID</code> call gets you data of this element from the database, which also contains the <code>element_ID</code> and with that the last part of the <code>URI</code>. Right now clients are using <code>element_ID</code> from the body, but changing them would be no problem, <em>if it should not be this way in a <code>RESTful API</code></em>.</p>
  
  <h2>General Question</h2>
  
  <p><strong>Is it a problem to send <code>URI</code> parts in the response body?</strong><br>
  (and if so should these parts be changeable)<br>
  Should the data be removed from the response body so clients have to use the <code>URI</code> to extract needed information? The main problem (additional to unnecessary overhead because of redundancy) I see is when clients want to change fields relevant for building the <code>URI</code> (e.g. use <code>PUT</code> on <code>/element/$ID</code> and change the <code>element_id</code> field).<br></p>
  
  <h2>Examples</h2>
  
  <p>Would this be a problem (the <code>element_id</code> is also used for the <code>URI</code>):</p>
  
  <pre><code>{
      "name": "Robert",
      "element_id": 1337
      "links": [ {
          "rel": "self",
          "href": "http://domain.tld:8080/element/1337"
      } ]
  }
  </code></pre>
  
  <p>And what would happen if you make following call on this model</p>
  
  <pre><code>PUT http://domain.tld:8080/element/1337
  {
      "name": "Robert",
      "element_id": 1234
  }
  </code></pre>
  
  <p>Or should the model just look more like this?</p>
  
  <pre><code>{
      "name": "Robert",
      "links": [ {
          "rel": "self",
          "href": "http://domain.tld:8080/element/1337"
      } ]
  }
  </code></pre>