I'm creating tasks with various properties and I'm passing the JSON data from Angular frontend to Java based backend. Assignee is a property of the Task class at the moment. A new request came in to change the behavior: The user should be able to select multiple assignees upon creating a new task.
The way I want to handle this is that I want to create the same amount of tasks as the number of assignees passed. So if n users are passed with the various task data, n tasks would be created in the DB for each user as an assignee.
Previously I could only pass one assignee and the code for returning the POST request's response was the following:
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response save(TaskInDto taskInDto) {
// saving to DB, etc...
String taskId = createdTask.getId().toString();
URI taskUri = uriInfo.getAbsolutePathBuilder().path(taskId).build();
return Response.created(taskUri).build();
}
My question is regarding REST design: What should I return as a Result object to the user if multiple objects were created?
If a POST request is creating multiple objects, clients will expect back a response entity containing links to each created resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With