title: Clear API errors [UWP]
body: <p>I have a problem with my API, the GET, POST, DELETE and PUT work perfectly. but if for some reason at the time of making a PUT or a POST I generate errors (404, 400, 500, etc) and it is normal that in some times for any query I generate errors ... the problem is that the next Once I go back to do a POST or PUT (being aware that it is ok) the error is stored and it does not let me make the new query ... I do not know what to do or what is wrong. <strong>but the GET is still working</strong></p>
  
  <p>THIS IS THE CONTROLLER CODE:</p>
  
  <pre><code>  [HttpGet("{id}")] //GET
    public async Task&lt;IActionResult&gt; Get(long id)
    {
       if (id == 0)
       return BadRequest();
       var tercero = await repository.GetAsync(id);
       if (tercero == null)
          return NotFound();
       else
          return Ok(tercero);
     }
  
     [HttpPost] //POST
     public async Task&lt;IActionResult&gt; Post([FromBody]Tercero tercero)
     {
       try
       {
           return Ok(await repository.InsertAsync(tercero));
       }
       catch(Exception e)
       {
           return BadRequest(e.ToString());
       }
     }
  
     [HttpPut("{id}")] //PUT
     public async Task&lt;IActionResult&gt; Put([FromBody]Tercero tercero, long Id)
     {
        if (tercero.Id != Id)
          return BadRequest("No hay correlacion entre el id y el objeto");
  
        try
        {
            return Ok(await repository.UpdateAsync(tercero, Id));
        }
        catch (Exception e)
        {
             return BadRequest(e.ToString());
        }
      }
  
      [HttpDelete("{id}")] //DELETE
      public async Task&lt;IActionResult&gt; Delete(long id)
      {
        try
        {
            await repository.DeleteAsync(id);
            return Ok();
        }
        catch (Exception e)
        {
            return BadRequest(e.ToString());
        }
      }
  </code></pre>
  
  <p>I have other controllers and with all the same thing happens. I do not know if he finds something to clean up the error</p>
  
  <p><strong><em>THIS IS WHAT HAPPENS</em></strong></p>
  
  <p>STEP 1:
  I do a POST with a new User</p>
  
  <p><em>It returns the model of the query with a 200 OK</em></p>
  
  <p><a href="https://i.stack.imgur.com/YUFlz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YUFlz.png" alt="It returns the model of the query with a 200 OK"></a></p>
  
  <p>STEP 2: 
  I generate an error giving the same code in one of the fields what the database does not allow me.</p>
  
  <p><em>It shows me the error with a 400 Bad Request</em></p>
  
  <p><a href="https://i.stack.imgur.com/Mwym0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mwym0.png" alt="enter image description here"></a></p>
  
  <p>STEP 3: I realize my mistake and I decide to correct it to make a correct POST</p>
  
  <p><em>It gives me the same error</em></p>
  
  <p><a href="https://i.stack.imgur.com/tKTll.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tKTll.png" alt="enter image description here"></a></p>
  
  <p><strong>WHY? How can i fix it?</strong></p>