C#
[error 처리] The JSON value could not be converted to...
NY안나
2020. 10. 19. 12:46
.net core api 제작 중 client 에서 post 로 객체를 json으로 말아서 전달 했는데
400 error 로 메세지 'The JSON value could not be converted to...' 가 반환된다.
객체 내부에 DateTime Property에서 걸린 것이다.
해당 .net core 3.1 버전이고, 기본지정된 Json 라이브러리가 System.Text.Json 인 것 같아 NewtonSoft Json 라이브러리를 Controller에 추가해 주라는 말이 많다.
ConfigureService 함수에 services.AddControllers().AddNewtonsoftJson(); 로 변경 해주었더니..
또 다시
'IMvcBuilder' does not contain a definition for 'AddNewtonsoftJson'
요런 Error 가 반환된다.
Nuget 들어가서 Microsoft.AspNetCore.Mvc.NewtonsoftJson 요거 설치 해 주라기에 설치해주었더니 해결 완료!