REST GET verb with parameters

跟風遠走 提交于 2019-12-03 02:48:54
manuel aldana

Parameters are perfectly OK, especially for search-resources like in your case (querying a set of journals).

I recently answered similar question (path vs. parameter)

REST doesn't make query parameter "illegal" in any way. It's an architectural style, mainly about driving the application by exchanging representations. Considering URIs are meant to be opaque, there's no real difference between http://example.com/page/1 and http://example/?page=1 for example, as far as REST is concerned (it ultimately depends on the representations that are sent, but the choice or URI style tends to be an implementation detail).

What matters is how the client are going to find out about the URIs of your reports. HTML can do this very well with forms and query parameters. Whether your service is for browser consumption or another agent doesn't really matter, you can use the same principles. You could have HTML forms (or equivalent if your client isn't a browser) if you want it to be more flexible or via explicit links on your top page. (You may find it's easier to split the range into two parameters, like "from" and "to", if you want this to be more dynamic.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!