Getting “reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response” while mocking a third part API

My Spring boot API is consuming a third part API using WebClient DemoAPIController @RestController public class DemoAPIController { @Autowired DemoService demoService; @GetMapping(“/mytest”) public Mono<UserType> getUserType() { return demoService.getUserType(); } } DemoService.java @Component public class DemoService { @Value(“${base.url}”) private String baseUrl; public Mono<UserType> getUserType() { System.out.println(“baseUrl:” + baseUrl); WebClient webClient = WebClient.builder().baseUrl(baseUrl) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .defaultHeader(“apikey”, “test”).build();…

Getting CORS error in Angular 8 while trying to post data to Asp.net core web api

I am making CRUD using Angular 8 and Asp.net core. Everything works fine until I submit data. It returns me following error. Access to XMLHttpRequest at ‘http://localhost:56975/api/PaymentDetail‘ from origin ‘http://localhost:4200‘ has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. I already add Microsoft.AspNetCore.Cors package. This is…

How to write custom console command for ASP.NET MVC application? To execute like “dotnet run my-custom-command arg1 arg2”

I’m trying to find information over the internet, but everything around points just to dotnet cli utility. It seems nobody or almost nobody asked for feature to have ability to run console command from MVC app. My reasons to have it: I have MVC app and I want to create custom console commands to: –…

ASP.Net Core 2.2 – separate serializer settings for input and output

ASP.Net Core 2.2 allows to set serializer settings using MvcJsonOptions.SerializerSettings property. The problem is that it affects both input and output. Is there a way to have separate options for input (deserialization) and output (serialization)? In particular, I need to set a different behavior for NullValueHandling settings: ignore null errors for non-nullable fields when deserializing…

Request method ‘POST’ not supported when use @RequestParam

I am using Spring MVC. And get this error: Request method ‘POST’ not supported Java @RequestMapping(value = “/jdbcInsertGuest”, method = RequestMethod.POST) public void jdbcInsertGuest(@RequestParam(value = “guestName”) String guestName, @RequestParam(value=”comment”) String comment) { Guest guest = new Guest(); guest.setGuestName(guestName); guest.setComment(comment); jdbcExample.insertGuest(guest); } JSP <form name=”jdbcInsertGuest” method=”POST”> <table> <tr> <td><b>Name: </b></td> <td><input type=’text’ name=’guestName’/></td> </tr> <tr> <td><b>Comment:…