문제

Can a hyperlink in a REST response contain reference to the result of a differing attribut in the response?

For example, I'm attempting to design an API response that has a link to gather statements for the previous six months, but I want this URI to be relative to the start_date of the statement returned in the original GET request.

"start_date" : “12/1/13”,
"end_date" : “12/31/13”,
"previous_enrollments" : {
   "name" : “enrollment_history”,
   "title" : “Previous Six Months”
   "link" : "/offers/1004/enrollments?", // Where start date is 6 months prior to the        current response
   "rel" = "self",
   "method": "GET",
}
도움이 되었습니까?

해결책

Absolutely, that's one of the core tenets and benefits of HATEOAS.

However your URI looks incomplete with that trailing "?" on it. You should probably return the entire URI - parameters included - that they can blindly GET without having to parse and manipulate it in order to follow it. For example:

"link" : "/offers/1004/enrollments?start=1/1/13&end="7/1/13

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