I've read this answer as a solution to POSTing an entity with nested entities. But I want to make a RESTful POST request.
That is, I want nested entities to be represented with links.
As an example, suppose my client wants to POST a student:
class Student {
String name;
Address address;
}
RepresentationModel<Address> address = //feign call to get previously saved address from Spring Data Rest endpoint
Student student = new Student();
student.setName("name");
student.setAddress(address.getContent());
client.save(student); //feign call to save student
This last call fails because Spring Data Rest expects address to be represented as a URI instead of a nested object. How can I add the URI?
I've tried making the Student address field be of type RepresentationModel<Address> but this doesn't work. The server throws an error saying addressId can't be null.