You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setting request-body-strict does not work properly.
Desired (Correct) behavior:
REST methods Put, Post, Patch entity payloads can include primary key properties. They are ignored.
Actual (incorrect) behavior:
Exception. Entity payloads including primary key properties result in exception.
Status
It should be noted that the desired behavior is the only reason for the setting.
Workaround
Developers using .NET (at least) must unceremoniously remove the primary key properties from their models before calls.
publicasyncTask<Player>UpdateAsync(Playerplayer){ArgumentNullException.ThrowIfNull(player);// remove primary keyvarnode=JsonSerializer.SerializeToNode(player);node?.AsObject().Remove("id");varurl=$"{baseUrl}/Id/{player.Id}";varresponse=awaithttp.PutAsJsonAsync(url,node);varjson=awaitresponse.Content.ReadAsStringAsync();varroot=JsonSerializer.Deserialize<PlayerRoot>(json)??thrownewException("Response Json is invalid.");returnroot.Players.Single();}
This is what it should look like:
publicasyncTask<Player>UpdateAsync(Playerplayer){ArgumentNullException.ThrowIfNull(player);varurl=$"{baseUrl}/Id/{player.Id}";varresponse=awaithttp.PutAsJsonAsync(url,player);varjson=awaitresponse.Content.ReadAsStringAsync();varroot=JsonSerializer.Deserialize<PlayerRoot>(json)??thrownewException("Response Json is invalid.");returnroot.Players.Single();}
The text was updated successfully, but these errors were encountered:
After some investigation it seems that the issue is really with auto-generated primary keys. These operations work with request-body-strict but not if the primary key is autogenerated. Fix is incoming.
What happened?
Setting
request-body-strict
does not work properly.Desired (Correct) behavior:
REST methods Put, Post, Patch entity payloads can include primary key properties. They are ignored.
Actual (incorrect) behavior:
Exception. Entity payloads including primary key properties result in exception.
Status
It should be noted that the desired behavior is the only reason for the setting.
Workaround
Developers using .NET (at least) must unceremoniously remove the primary key properties from their models before calls.
This is what it should look like:
The text was updated successfully, but these errors were encountered: