Is it ok for a REST api to be exposed via two HTTP methods? -
the problem have complex query string search api , want let users have convenience of using body instead. want allow both , post(or put).
i understand there debate of search being read operation , should per rest standards. put not cache friendly understand. know ok deviate @ times rest standards. make sense have 2 methods client's convenience?
using post
directly query data not thing, precisely reasons mentioned. if search string complex, perhaps simplify things splitting querying process in 2 steps - 1 involving post
, , 1 involving straight get
s.
the first step creates query template using post
. query string sent via message body, , becomes new resource users can query through get
. query string allows parameters, in way similar sql queries. taking wild guess @ how query might look, here example:
(username = $name) || (createdbefore > $asof && deleted=false)
your users post
in message body, , new resource identifier back. resource identifies parameterized "view" data. let's resource id view aabb02kjh
. users can query this:
https://app.yourserver.net/aabb02kjh?name=airboss&asof=20140101
this adds complexity api, lets users define , reuse query templates simple , standard query strings.
Comments
Post a Comment