My WebAPI request doesn't work when I ask for NoContent. What do I do?

46 views Asked by At

Can't for the life of me, get this to work.

 [HttpGet, Route("GetCategories/{id:int?}")]
 public IHttpActionResult GetCategories(int id)
 {
      var @event = _repositoryService.FindEvent(id);
      if (@event == null || @event.Active != 1)
      { 
        return new ResponseMessageResult(Request.CreateErrorResponse(HttpStatusCode.NoContent, "Nothing to show."));
      }
 }

When I call in Postman http://localhost/api/GetCategories/33 I get no response at all. I can step through the code, but the response is not given. It looks as though the call is throwing an error. If I change the return to be

return NotFound();

Then I get a 404...but I need to return NoContent (204). What am I missing?

0

There are 0 answers