Reputation: 337
I'm using Spring Data MongoDB and Spring Data Rest to create a REST API which allows GET, POST, PUT and DELETE operations on my MongoDB database and it's all working fine except for the update operations (PUT). It only works if I send the full object in the request body otherwise variables didn't send it in the rquest are null.Can someone guide me to solve this.
@PutMapping("/update/{id}")
public void update(@Valid @RequestBody Facture facture, @PathVariable("id") String id){
Optional<Facture> factureData = factureRepository.findById(id);
facture.setId_facture(id);
this.factureRepository.save(facture);
}
Upvotes: 1
Views: 209