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
I tried use a Either<string, T> as property of a view model in one web api with .NET CORE 3.0
When I sent a string as value of the property, it deserialize correctly, but when property values is an any T, the Either type identify as TRight correctly but can't deserialize it.
*When I set the same data directly from code C# it's works correctly
Hello, it may have been a mistake typing here in Issue but I see your JsonProperty is ("loongitude") and in payload this "longitude", can you check if this is the problem?
Hi!
I have make a mistake on type the code here. The deserialization doesn't occurs correctly. I think that the model binder provider doesn't know create a instance of Either type
Model Binder has its limitations, and the Either type is very complex for it to convert correctly, I think that to resolve it would be to change the payload to a simpler class and do the conversion later.
I tried use a Either<string, T> as property of a view model in one web api with .NET CORE 3.0
When I sent a string as value of the property, it deserialize correctly, but when property values is an any T, the Either type identify as TRight correctly but can't deserialize it.
*When I set the same data directly from code C# it's works correctly
Below I pasted some evidencies of this issue
csproj
Microsoft.Net.Compilers Version="3.3.1"
System.ValueTuple Version="4.5.0"
Tango Version="3.1.2"
View Model
`public class SampleRequestModel
{
[JsonProperty("option")]
public int Option{ get; set; }
Controller
`[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
public async Task Post([FromBody] SampleRequestModel model)
{
string filter = string.Empty;
Request
1 - Works
curl -X POST
http://localhost:50535/api/values
-H 'Accept: /'
-H 'Accept-Encoding: gzip, deflate'
-H 'Cache-Control: no-cache'
-H 'Connection: keep-alive'
-H 'Content-Length: 36'
-H 'Content-Type: application/json'
-H 'Host: localhost:50535'
-H 'Postman-Token: 45c3d866-2cd1-4266-8364-b22dd6aa8283,660d6618-8e8d-4ef5-983b-00ee0e6bb9a9'
-H 'User-Agent: PostmanRuntime/7.20.1'
-H 'cache-control: no-cache'
-d '{
"option": 1,
"payload": "jose"
}'
2- Dont work
curl -X POST
http://localhost:50535/api/values
-H 'Accept: /'
-H 'Accept-Encoding: gzip, deflate'
-H 'Cache-Control: no-cache'
-H 'Connection: keep-alive'
-H 'Content-Length: 36'
-H 'Content-Type: application/json'
-H 'Host: localhost:50535'
-H 'Postman-Token: 45c3d866-2cd1-4266-8364-b22dd6aa8283,0a834c05-a2d6-4faf-81e7-5ea53e6a4a3d'
-H 'User-Agent: PostmanRuntime/7.20.1'
-H 'cache-control: no-cache'
-d '{
"option": 1,
"payload": {
"latitude": 23.123,
"longitude": 48.334
}
}'
The text was updated successfully, but these errors were encountered: