title: What is the REST way to update a record without primary key?
body: <p>I've created a REST API. According to my design, we have to store user's blood sugar level per <strong>daily basis</strong>.</p>
  
  <p><strong>The problem is:</strong></p>
  
  <ul>
  <li>I want to use single endpoint for the insert and the update operations</li>
  <li>I don't want to use primary key of the <code>blood-sugar</code> resource in the URI because i want to store only the <strong>last value</strong> for a <strong>single day</strong>.</li>
  </ul>
  
  <hr>
  
  <p>For example if I make this call</p>
  
  <pre><code>POST https://{host}/users/1/blood-sugar/
  
  {
      "measureDate": "2019-05-04",
      "bloodSugarLevel": 86
  }
  </code></pre>
  
  <p>It will create a <code>blood-sugar</code> resource and the database will assign and ID (let's say <code>ID=333</code>)</p>
  
  <p>It's OK until here.</p>
  
  <p>Then, I want to be able to make a second request with same date but  different blood sugar level. As a result, i want to the backend should find the previous <code>blood-sugar</code> resource (with <code>ID=333</code>) and update the <code>bloodSugarLevel</code> field, because we already have a record for this day (<code>2019-05-04</code>). I don't want to send <code>ID=333</code> in the request body or URI.</p>
  
  <pre><code>POST https://{host}/users/1/blood-sugar/
  
  {
      "measureDate": "2019-05-04",
      "bloodSugarLevel": 105 # only this value is different
  }
  </code></pre>
  
  <p><strong>My question is:</strong></p>
  
  <p>Is there any way to achieve this (or similar) result with REST? You can offer me to change the VERB or the URI or the request body.</p>
  
  <blockquote>
    <p>Note:
    If I was doing this with WCF or similar thing, only single method would satisfy the all my requirements. For example: <code>CreateOrUpdateBloodSugarLevel(int userId, DateTime measureDate, int bloodSugarLevel)</code></p>
  </blockquote>
  
  <p>Thanks.</p>