79505474

Date: 2025-03-13 05:17:42
Score: 1
Natty:
Report link

All I have to do is wrap the entity in org.springframework.hateoas.EntityModel and the URI will be perfectly converted

    @RequestMapping(method = { RequestMethod.PUT }, path = "/{pos}", consumes = {MediaType.APPLICATION_JSON_VALUE, "application/hal+json"})
    public ResponseEntity<Activity> edit(@PathVariable("pos") long pos, @RequestBody    EntityModel<Activity> activity) {

        // custom logic...

        Activity updated = repository.save(activity);
    
        return ResponseEntity.ok(updated);
    }
Reasons:
  • Blacklisted phrase (1): I have to do
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Meini