The JSON value could not be converted to System.Nullable`1[System.DateTime]. Path: $.addTime | LineNumber: 0 | BytePositionInLine:
Blazor 使用WebApiClientCore报错
是因为Json格式化时候 日期时间中间必须要带T 解决方案就是yyyy-MM-dd HH:mm:ss 中间增加个T
//解决方案
改成yyyy-MM-ddTHH:mm:ss
x
1
builder.Services.AddHttpApi<IServiceTest>(c =>2
{3
//设置请求前缀为当前的域名4
c.HttpHost = new Uri(builder.HostEnvironment.BaseAddress);5
// 报错则或者整个去掉 或者格式化字符串增加T6
c.JsonSerializeOptions.Converters.Add(new JsonLocalDateTimeConverter("yyyy-MM-ddTHH:mm:ss"));7
});

浙公网安备 33010602011771号