I`m trying to do post request:
public StudioResultDto createStudio(@RequestBody StudioDto studioDto) {
var studioResultDto = new StudioResultDto();
BeanUtils.copyProperties(studioDto, studioResultDto);
studioResultDto.setId(registrationService.register(convertToEntity(studioDto)));
return studioResultDto;
}
Here is my Studio.java class:
package com.spdu.haircutstudio.registration.web.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalTime;
public class StudioDto {
private String name;
private String phone;
private String url;
@JsonFormat(pattern = "hh:mm:ss")
private LocalTime startTime;
@JsonFormat(pattern = "hh:mm:ss")
private LocalTime endTime;
public StudioDto() {
}
public LocalTime getEndTime() {
return endTime;
}
public void setEndTime(LocalTime endTime) {
this.endTime = endTime;
}
public LocalTime getStartTime() {
return startTime;
}
public void setStartTime(LocalTime startTime) {
this.startTime = startTime;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
But after doing request I got warning. Jackson because of some reason can't deserialize request body to my dto. Why does it happened? Body of request is:
{
"endTime": {
"hour": "0",
"minute": "0",
"nano": 0,
"second": "0"
},
"name": "string",
"phone": "string",
"startTime": {
"hour": "0",
"minute": "0",
"nano": 0,
"second": "0"
},
"url": "string"
}
I have no response from the server. There is showing only 400 error. I tried to debug it, but I can't trace it in the method.