S
S
ScRsa2016-07-01 06:45:36
Java
ScRsa, 2016-07-01 06:45:36

How to use Spring HATEOAS (data rest) client side?

public class Filial {
    private long id;
    private String name;
}

public class User {
    private long id;
    private String name;
    @JoinColumn(...)
    private Filial filial;
}

To edit the user entity, the client must make a json request where instead of a branch a link to it
{
  "id": 1,
  "name": "Test T.T.",
  "filial": ""http://localhost/filial/2"
}

how to check this case? to have two entities for editing and for display?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kosarev, 2016-07-01
@jaxtr

Let's say you have a link to the user:
Then the link to the association with the branch will be:
And two links to the branches:

http://localhost:8080/filial/1
http://localhost:8080/filial/2

To change a user's association with a branch, you need to send a PUT request to the address of the user's association with the branch, indicating the link to the desired branch. The data type in the request must be text/uri-list, as specified here .
The request will be something like this:
curl -X PUT -H "Content-type: text/uri-list" http://localhost:8080/user/1/filial -d http://localhost:8080/filial/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question