HATEOAS links with PUT / POST

What would be the best way to present a HATEOAS link for POST / PUT / PATCH on a resource? These operations have a payload, but we will not be able to represent the payload in a HATEOAS link since they are not predefined and can be heavy. So, just point the endpoint and specify the operation?

Any examples or examples would be very useful for a JSON response with a HATEOAS POST / PUT / PATCH link.

+7
design rest hateoas hypermedia api-design
source share
1 answer

Links consist of two elements: href and rel . href contains an explicit URL to search for a resource. rel identifies the relationship between the current resource and the link resource. rel should be used to determine which HTTP method is acceptable and how to use the link.

The following is a quote from the RESTful cookbook web services section 5.4:

The link relationship type conveys the role or purpose of the link. When clients and servers agree to understand these types, clients can find and use URIs from the links.

For example, edit is a standard reference relation that has explicit details , including usage information for GET , PUT , POST , DELETE .

Relationships can be expanded and you can add your own.

+1
source share

All Articles