I have an application in Angular IO where it is a client of a Java service. I have a search where I want to pass many search criteria. Then I created a object for this.
export class CriteriosPesquisa{
public opcaoSelecionada: string;
public diaDe: Date;
public diaAte: Date;
public numNfe: string;
}
When I made my search, I pass the object in the body of my requisition Get. ( The result I will show in one grid ) Aparently my problems are because I am using body with GET.
public getNfes(criterios: CriteriosPesquisa): Observable<Array<Nfe>>{
const myHeaders = new Headers();
myHeaders.append('Content-Type', 'application/json');
// const myParams = new URLSearchParams();
// myParams.append('criterios', criterios);
const options = new RequestOptions({ headers: myHeaders, /*search: myParams,*/ body: JSON.stringify(criterios) });
return this._http.request(`${URL_API}nfes`, options)
.map(response => {
return response.json();
});
}
2018-05-12 23:34:19.740 WARN 1076 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public java.util.List br.com.minhasCompras.service.NfeService.buscarNfe(br.com.minhasCompras.eo.Criterios)
@RequestMapping(value = "/nfes")
public List<Nfe> buscarNfe(@RequestBody Criterios criterios){
System.out.println(criterios.getOpcaoSelecionada());
System.out.println(criterios.getNumNfe());
System.out.println(criterios.getDiaAte());
System.out.println(criterios.getDiaDe());
return new ArrayList<Nfe>();
}
Do you know something abou this ? How I can pass a object for my client with GET ?