0

Context

I m actually developping a simple application in which I need to use REST level 3 HATEOAS.

I m having two entities :

  • User
  • Billing

I need, when I add a billing, to reference the user inside of it.

Questions

What are the informations I should send to my backend, from my frontend app, to add the hateoas reference, inside the billing ressource, concerning the user ?

I mean, inside the body of the request, should I send the url of the user ressource ? Or should I send the id of the user, and then making an url discovering to get the real user url ?

mfrachet
  • 8,772
  • 17
  • 55
  • 110
  • You could take a look at the accepted answer of http://stackoverflow.com/questions/12879975/spring-data-rest-uri-vs-entity-id although it is Spring, but relates to HATEOAS in general. – Smutje Jul 02 '15 at 09:01
  • I think you may be misunderstanding how HATEOAS works. With HATEOAS the client should never have to know any urls. Instead, the server responds with any urls that are valid. In a truly RESTful service the client should only have to know 1 url. It should be able to navigate to any point from there. [Here's](https://spring.io/understanding/HATEOAS) a very simple explanation. I would personally recommend looking at one of the existing HATEOAS specifications like my personal favorite [SIREN](https://github.com/kevinswiber/siren). – Tim Martin Jul 10 '15 at 00:33
  • In you reply, you tell that the client should never know url, and then that server sends valid url to client. I m misunderstanding this point :-/. Actually, my problem is not for displaying valid links, it's, how should I do to post data and reference it through links ? Should I send the full url ? Or only the Id, and then I make some jobs to manage this ? – mfrachet Jul 10 '15 at 06:28

0 Answers0