What I aim to achieve:
I need to send two parameters from the front-end to the back-end.
This is the code snippet:
In TypeScript file:
activeFromActiveToQuery(req?: any): Observable<ResponseWrapper>{
const options = createRequestOption(req);
options.params.append("active_from", req.active_from.toString());
options.params.append("active_To", req.active_to.toString());
return this.http.get(this.resourceActiveFromActiveToURL, options)
.map((res: Response) => this.convertResponse(res));
}
checkOverlappingDates (recommendedSection: RecommendedSection) {
this.activeFromActiveToQuery({
active_from: recommendedSection.activeFrom,
active_to: recommendedSection.activeTo
}).subscribe((data) => {
var retValue;
if(data.json == ""){
retValue = false;
}else{
retValue = true;
}
return retValue;
In Java Resource class:
public ResponseEntity<List<RecommendedSection>> getRecommendedSectionActiveFromAndActiveToMatching(@RequestParam("active_from") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime active_from,
@RequestParam("active_to") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime active_to){
log.debug("REST request to get active_from and active_to: {}", active_from, active_to);
List<RecommendedSection> entityList = recommendedSectionService.findRecommendedSectionActiveFromAndActiveToMatching(active_from, active_to);
return ResponseEntity.ok().body(entityList);
}
The Issue at hand:
An error message stating the following Bad Request is received:
"Failed to convert value of type 'java.lang.String' to required type 'org.joda.time.DateTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@javax.validation.Valid @org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat org.joda.time.DateTime] for value '[object Object]'; nested exception is java.lang.IllegalArgumentException: Invalid format: "[object Object]""
Apologies if the solution appears straightforward. I have struggled to find a fix that works for me.
Any suggestions on how to resolve this issue?