We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request-body-strict
Setting request-body-strict does not work properly.
REST methods Put, Post, Patch entity payloads can include primary key properties. They are ignored.
Exception. Entity payloads including primary key properties result in exception.
It should be noted that the desired behavior is the only reason for the setting.
Developers using .NET (at least) must unceremoniously remove the primary key properties from their models before calls.
public async Task<Player> UpdateAsync(Player player) { ArgumentNullException.ThrowIfNull(player); // remove primary key var node = JsonSerializer.SerializeToNode(player); node?.AsObject().Remove("id"); var url = $"{baseUrl}/Id/{player.Id}"; var response = await http.PutAsJsonAsync(url, node); var json = await response.Content.ReadAsStringAsync(); var root = JsonSerializer.Deserialize<PlayerRoot>(json) ?? throw new Exception("Response Json is invalid."); return root.Players.Single(); }
This is what it should look like:
public async Task<Player> UpdateAsync(Player player) { ArgumentNullException.ThrowIfNull(player); var url = $"{baseUrl}/Id/{player.Id}"; var response = await http.PutAsJsonAsync(url, player); var json = await response.Content.ReadAsStringAsync(); var root = JsonSerializer.Deserialize<PlayerRoot>(json) ?? throw new Exception("Response Json is invalid."); return root.Players.Single(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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: