I have clone the example "todo-list" from github and without modifying anything the @post todo-lists is created without. then I use the responsed "Id" to @post /todo-lists/{id}/todos and it gave error
Unhandled error in POST /todo-lists/3/todos: 500 Error: Property "todoListId" cannot be changed! at Object.constrainDataObject (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules@loopback\repository\dist\repositor ies\constraint-utils.js:49:19) at DefaultHasManyRepository.create (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules@loopback\repository\dist\rela tions\has-many\has-many.repository.js:21:59) at process._tickCallback (internal/process/next_tick.js:68:7)
I also tried to create everything by myself following the example. https://loopback.io/doc/en/lb4/HasMany-relation.html It sill give the same error.
PS. I have posted this on the loopback github but I don't know if that's the right place to post. So, I posted it here instead.
You must be sending todoListId in the request body. Remove that. Loopback juggler automatically attaches that value upon saving. Below request body worked for me.
{
"title": "Testing 123",
"desc": "This is a testing description",
"isComplete": true
}