0

I am trying to pass an HTML form through a downstream API using Springboot and Thymeleaf but the response I am getting is:

org.springframework.web.client.HttpClientErrorException$BadRequest: 400 : "[{"code":"SERVICE_GATEWAY_ERROR","message":"Received bad request - appointmentDate and appointmentTime can't be empty"}]"

This is from html:

<label>appointmentDate:</label>
<input type="date" th:field="*{appointmentDate}" /><br/>

<label>appointmentStartTime:</label>
<input type="time" th:field="*{appointmentStartTime}"  step="1" /><br/>

This is from my controller

@PostMapping("/showform")
@ResponseBody
public String submitForm(@ModelAttribute ("appointment") Appointment appointment) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE));
    headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
    HttpEntity<Appointment> entity = new HttpEntity<Appointment>(appointment,headers);

    String responds = restTemplate.exchange(
            "downstreamapiurl", HttpMethod.POST, entity, String.class).getBody();*/


    return "registersuccess";
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
autoboss
  • 11
  • 3

0 Answers0