1

I want to give users of my application to specify search parameters with query builder. Something like this http://dncrews.com/angular-elastic-builder/examples/ Or this http://mfauveau.github.io/angular-query-builder/

Front-end which is written in AngularJS comunicates over HTTP with back-end. On back-end i want to implement RESTful API. And i cannot find any recomendations how to get list (which usually retrived throug HTTP GET request) with large amount of search parameters in RESTful way. In my case user can build query that will exhaust URL length limit. Because of that i cannot use GET request type.

2 Answers 2

1

Simple, use POST. It doesn't have any limitations on amount of data.

Sign up to request clarification or add additional context in comments.

Comments

0

A common approach is to use POST to create a /search-criteria resource which contains all your parameters. Then do the GET with a query parameter ?searchCriteria={id}.

3 Comments

I like this approach, but it requires 2 requests to server. Maybe create resource /search, which will return results after receiving query through POST ?
You can do that if you choose. Strictly speaking, it is RPC and not RESTful, but it's not an uncommon approach. For very complex search criteria, you might want to allow users to remember their choices so they don't have to re-enter them. Also, I very much doubt the two requests will be noticeable to end users, but that's what testing is for.
I worry more about additional requests for server to handle. I have desided to implement saved search query as separate resource. So users can store templates and reuse them or modify query and request different search configurations without storing them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.