문제

I'm developing a RESTful web service and want to follow the HATEOAS concept. There are tons of examples out there on what should a GET response look like according to HATEOAS, but I couldn't find a good example on response after a successful resource creation.

How should the HATEOAS part of the response headers and body look like?

Thanks for help

도움이 되었습니까?

해결책

Probably the most salient piece of information that can be returned from a resource creation request is a Link to the resource itself, usually as a self link in the response. Other than this the body of the response for creation of a resource could be many things: empty, some information about the resource created or (most likely) a representation of the resource itself.

If the request creates a new resource you should probably be returning a 201 CREATED status code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top