I updated an ASP.NET Core 2.2 API to ASP.NET Core 3.0 and I am using System.Json:
services
.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddJsonOptions(x => {})
I then tried to post JSON data using Angular 8, which was working before:
{
"name": "John"
"userId": "1"
}
The model in the ASP.NET Core 3.0 API is:
public class UserModel {
public String Name { get; set; }
public Int32? UserId { get; set; }
}
And the API Controller action is as follows:
[HttpPost("users")]
public async Task<IActionResult> Create([FromBody]PostModel) {
}
When I submit the model I get the following error:
The JSON value could not be converted to System.Nullable[System.Int32].
Do I need to do something else when using System.Json instead of Newtonsoft?