REST: different representations of the same data

How to structure an API where the same data can be requested in a different format, in the RESTful format. For instance.

GET /person/<id>  //get the details of resource <id>

Now, depending on the requirements of the client (browser), the data can be sent as html (say, normal rendering) or Json (for example, an ajax call). Therefore, my doubts:

  • Can I keep the same URL for both requests or leave them separately?
  • How to determine if a request for html / Json is on the server. The request type is the same (GET). So which parameter should I consider.
  • How to determine the difference in the data type of the client (html / Json) \

thank,

BSR.

+3
source share
2 answers

: REST Content-Type: Accept?

.

URL- ?

, . , .

, html/Json . (GET). , .

Accept, .

(html/Json)\

"Content-Type".

+6

?

0

All Articles