What I want to do:
I want to pass on two parameters from front-end to the back-end.
This is my code:
In TS-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 Problem:
I get a Bad Request which tells me the following:
"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]""
Im sorry if this is a really simple one to solve. I simply couldn't find a solution that worked for me.
But any idea how to solve this?