As You know the put request looks like this :
put(url: string, body: any, options?: RequestOptionsArgs): Observable<Response>
So in angular for my case it looks like this :
updateIntervention(id:number,idDev:number){
if(this.authService.getToken()==null) {
this.authService.loadToken();
}
return this.http.put(this.host+"/updateIntervention/"+id,idDev,{headers:new HttpHeaders({'Authorization':this.authService.getToken()})});
}
So in spring-data(back end) , the method waiting for a PUT request should be something like for example:
@RequestMapping(value="/updateIntervention/{id}",method = RequestMethod.PUT)
public Intervention update(@PathVariable Long id , @RequestBody B obj){
...
}
So obj here is an object of class B which has an attribte of type Long that will return the body of the PUT request sent by angular5 .
my problem is i keep creating these different classes in spring-data (because somtimes i send only one attribute in body , that's why i create a new class to represent it ) so i can get the body sent by angular even thought it contains only one attribute , as in this case idDev .
are there any better ways to avoid creating new classes in spring-data so i cant get the idDev send by front end in body ?
If i put only for exemple :
public Intervention update(@PathVariable Long id , @RequestBody long idDev){
i get error of deserialization etc ..
Any idea or it is not possible ?