onejigtwojig onejigtwojig - 3 months ago 7
reST (reStructuredText) Question

Rest Standard: Path parameters or Request parameters

I am creating a new REST service.

What is the standard for passing parameters to REST services. From different REST implementations in Java, you can configure parameters as part of the path or as request parameters. For example,

Path parameters
http://www.rest.services.com/item/b

Request parameters
http://www.rest.services.com/get?item=b

Does anyone know what the advantages/disadvantages for each method of passing parameters. It seems that passing the parameters as part of the path seems to coincide better with the notion of the REST protocol. That is, a single location signifies a unique response, correct?

Answer

Paths tend to be cached, parameters tend to not be, as a general rule.

So...

GET /customers/bob

vs

GET /customers?name=bob

The first is more likely to be cached (assuming proper headers, etc.) whereas the latter is likely not to be cached.

Comments