I just realized that the problem is not in the backend, but in the frontend that sending the request. There is a POST request specifying the model id, but in this case we are creating a model, so we do not need to specify the id so the correct request should be POST /api/chatmessages
instead POST api/chatmessages/0