1

I've read a lot about RESTful, but I have always had a hard time figuring out how I'd use it with a very long query string. This is an in-house project, and it won't always have a simple /someAction or someController/12/14/my-article-I-want-indexed.

I'm not worried about SEO because the application is not on the Internet.

My querystrings are long sets of ?somevar=123456&x=4785&y=394958.......

Most examples for REST I have seen are for SEO and simple web apps like a blog, maybe a CMS.

Is REST not the best practice for a situation where having long URLs with lots of variables in the querystring is the norm?

Here is an example of what looks to me like a non-RESTful way:

http://www.target.com/s?searchTerm=bicycle&category=0%7CAll%7Cmatchallpartial%7Call+categories&lnk=snav_sbox_bicycle

Is this link an illustration bad practice and design?

It's not a super long URL, but it illustrates that not everyone uses REST, if I understand REST. I know the reasons for REST, pretty URLs, hackable URLs, etc. I'd like to design my application well but feel like it would be shoehorned into a pattern I don't need. What is the best practice here?

  • 1
    Questions about best/worst practices do not work well on this site. Could the question be reworded to address specific concerns you have? E.g. "does a long URL cause X with REST?" but then that is something easily testable anyway. – user22815 Aug 28 '14 at 15:07
  • The whole point of rest is to hide the implementation details and create readable URLs. They are best used when you have long unreadable query strings. The URL you provided could be represented as target.com/search/bicycle/category/0/match/partial – Cameron McKay Aug 28 '14 at 15:13
  • @CameronMcKay What if I had 50 variables in the URL? – johnny Aug 28 '14 at 15:44
  • @Snowman I thought it was a design question, so I asked it that way. – johnny Aug 28 '14 at 15:45
  • 1
    @johnny If you have 50 variables in your URL, then I think you have a design problem. – Cameron McKay Aug 28 '14 at 15:51
3

REST does not mean to not use URL params at all.

Your example demonstrates this very well. You can still see a 'search' as a REST resource. You implement a controller for it, though it only has one or two actions. (But details do not matter much in this case)

Everything data needed to perform the search can then be sent by using params. There is nothing about REST that forbids it. Actually those parts within the URL as used in REST are always 'resource identifiers' which your params are not.

Think of them as similar to the form data you may post from the new action (showing the form) to the create action (creating the new resource based on this form data). It is just normal to use params in REST. (And for SEO reasons you sometimes even see people using very long text identifiers in some places)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.