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
                // 报错则或者整个去掉  或者格式化字符串增加T
6
                c.JsonSerializeOptions.Converters.Add(new JsonLocalDateTimeConverter("yyyy-MM-ddTHH:mm:ss"));
7
            });
posted @ 2020-11-13 21:20  ToLing·  阅读(2849)  评论(0编辑  收藏  举报