Topic: REST, multiple id's

hi,
after reading some articles regarding REST im trying to find a solution for doing a REST call with multiple IDs.

one solution is to put a list of IDs together.
GET
/posts/ids=1,2,3,4,5

CONS:
  url length issue if i have 100 ids

second solution: multiple calls (Typhoeus, queue)
GET
/post/id=1
/post/id=2
/post/id=3

CONS
  probably an issue if i have to make 100 calls on load

is there a better solution?

thanks

pete

Re: REST, multiple id's

The second method,  it keeps you classically RESTful, and if performance becomes any issue there is always Rails caching,  i.e. put

caches_action :show in your controller

All your requests for posts would get cached,   and every time a request was made,  the controller would quickly server up the cached page without having to hit the database.  If the posts are editable by the posting user, you'd have to expire that particular page in the edit action.

The first method just wouldn't work really well!   It would be difficult or impossible to cache,  and you would be hitting the database every time you requested a show post.

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: REST, multiple id's

Actually I'm struggling to think of a time where I needed to display a group of records in that manner using the ids of each within the URL. Unless you are doing some sort of review on them where you need to view a few different posts.

If the example is posts then the groupings would possibly come from tags or grouped by pages (pagination).

I'm not sure doing multiple SQL calls is the best way to do this however, in my opinion it would be better to use:

select * from table_name where id in(1,2,3)

Last edited by SprySoft (2012-01-23 11:25:36)

Re: REST, multiple id's

Hi,

I am trying for the GET request for multiple id's and single name

/posts/ids=1,2&name=abc

but it is giving me an error

Failed to convert from type java.lang.String to type java.lang.Long for value '1,2';

Please help me. Thanks