I am trying to write a web api using abp.io and implementing NodaTime. Whenever I try to call the POST action, I get
The following errors were detected during validation.\r\n - The JSON value could not be converted to NodaTime.LocalDate.
I have configured NodaTime correctly in the module, I also tested it in a conventional .net 5 web api and is working correctly.
Here is my config:
private void ConfigureNodaSerialization()
{
Configure<JsonSerializer>(options =>
{
options.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
//options.Converters.Add(NodaConverters.LocalDateConverter);
});
}
I am using NodaTime.Serialization.JsonNet
I have also tried NodaTime.Serialization.SystemTextJson to no avail, same results.
..and here is the appservice:
[AllowAnonymous]
public class NodaTestAppService : TestAppService, INodaTestAppService
{
public Task PostNodaTest([FromBody]NodaTestDto dto)
{
return Task.CompletedTask;
}
public Task GetNodaTest(NodaTestDto dto)
{
return Task.CompletedTask;
}
}
The GET is working fine, problem is with POST.
This is the dto:
public class NodaTestDto
{
public LocalDate Date { get; set; }
public string NodaString { get; set; }
}
I suspect the problem is with Abp serialization.
I have my test solution on github here.
This is the curl for my attempted request:
curl -X 'POST'
'https://localhost:44333/api/app/noda-test/noda-test'
-H 'accept: /'
-H 'Content-Type: application/json'
-H 'RequestVerificationToken: CfDJ8N-JsQhR2mhIqO-RkZtn61KwWgiFfjD60I0EMa07QTooLF9dC8LPmQEDtTws8MpTUtl8b0gtuE-NAiBAXxHEu8IyU8-4w0MfVB4IeZTRsWwXIgzc7pQYReLYnV1IVp0icR5Aj-fMvBqRyvPaNTgVJBc'
-d '{ "date": "1991-08-28", "nodaString": "string" }'
