I'm writing a RESTful HATEOAS API. I have compound entities which I have to GET, POST and PUT. The GET part is easy, and has lots of examples. The response contains the entity's primitive attributes, and links to nested entities. For example:
{
"id":"2",
"firstName":"Brad",
"lastName":"Pitt",
"balance":1234.5,
"transactions":"http://localhost:8080/jersey-poc/api/v1.1/account/1/transactions",
"self":"http://localhost:8080/api/v1.1/account/1",
"accountType":"http://localhost:8080/api/v1.1/account/1/accountType"
}
The problem arises when I want to create or modify the account. I need to associate the account with an accountType. I can send the a POST request such as the following: {"firstName":"Michael","lastName":"Jackson","balance":300.0,"accountTypeId":5}
but that would break the HATEOAS paradigm. What is the best practice to POST/PUT compound entities?