I'm using KevinDockx-Jsonpatch library (v2.1.0 - GitHub) in a .NET Web API project to receive jsonpatch partial updates from a Web API.
I'm trying to add an element to an array with a patch like this:
[{
"op": "add",
"path": "/links/8",
"value": {
"linkName": "test",
"linkValue": "http://test.com",
"id": 0,
"websiteId": 123,
"valid": true
}}]
Unfortunately I'm getting this error: TargetLocationAtPathSegmentNotFound
It seems that the lib is checking not for the array position but for a path called links/4 and obviously it is not able to find it. I've also tried with links/- but there is the same problem.
My model on server is written using Entity Framework Code First approach.
So I have an object like this:
[Table("XXX.Websites")]
public partial class Website : Entity
{
[StringLength(255)]
public string Name { get; set; }
public virtual ICollection<Link> Links { get; set; }
}
Any suggestions on this?