This exemplar project includes multiple domain classes and a relationship between those classes.
- Request 1.
In Windows CMD,
curl -X POST -H "Content-Type:application/json" -d "{\"name\":\"My Library\"}" http://localhost:8081/libraries
In MacOS/Linux,
curl -X POST -H "Content-Type:application/json" -d '{"name":"My Library"}' http://localhost:8081/libraries
which returns
{"id":1,"name":"My Library"}
- Request 2. In Windows CMD,
curl -X POST -H "Content-Type:application/json" -d "{\"location\":\"Main Street nr 5\"}" http://localhost:8081/addresses
In MacOS/Linux,
curl -X POST -H "Content-Type:application/json" -d '{"location":"Main Street nr 5"}' http://localhost:8081/addresses
which returns
{"id":2,"location":"Main Street nr 5","library":null}
- Request 3.
curl -i -X PUT http://localhost:8081/libraries/1/address/2
which returns
{"id":1,"name":"My Library"}
- Request 4.
curl -X GET http://localhost:8081/addresses/2
which returns
{"id":2,"location":"Main Street nr 5","library":{"id":1,"name":"My Library"}}
Note that the value of "library"
has been updated from null
to {"id":1,"name":"My Library"}
.