When using the HAL module and the hal_json format, you must provide relationships for the entity. This is done through the _links parameter in the request. This is done to ensure that the entity is properly created with any relationships it requires, such as the entity type for a content entities bundle. Another example will be to create a comment over a RESTful interface. You will need to provide a _links entry for the user owning the comment.
The rest.link_manager service uses the rest.link_manager.type and rest.link_manager.relation and is responsible for returning the URIs for types and relations. By default, a bundle will have a path that resembles /rest/type/{entity_type}/{bundle} and its relations will resemble /rest/relation/{entity_type}/{bundle}/{field_name}.
Taking a user reference as an example, we will have to populate a uid field, as follows:
{
"_links": {
"type": {
"href": "http://127.0.0.1:8888/rest/type/node/page"
},
"http://127.0.0.1:8888/rest/relation/node/article/uid": [
{
"href": "http://127.0.0.1:8888/user/1?_format=hal_json",
"lang": "en"
}
]
}
}
Unfortunately, the documentation is sparse, and the best way to learn what _links are required is to perform a GET request and study the returned _links from the HAL JSON.