RestTemplate: How to send URL and query parameters together

I would use buildAndExpand from UriComponentsBuilder to pass all types of URI parameters. For example: String url = “http://test.com/solarSystem/planets/{planet}/moons/{moon}”; // URI (URL) parameters Map<String, String> urlParams = new HashMap<>(); urlParams.put(“planet”, “Mars”); urlParams.put(“moon”, “Phobos”); // Query parameters UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url) // Add query parameter .queryParam(“firstName”, “Mark”) .queryParam(“lastName”, “Watney”); System.out.println(builder.buildAndExpand(urlParams).toUri()); /** * Console output: * http://test.com/solarSystem/planets/Mars/moons/Phobos?firstName=Mark&lastName=Watney … Read more

Are query string keys case sensitive?

The RFC for URIs says: 6.2.2.1. Case Normalization When a URI uses components of the generic syntax, the component syntax equivalence rules always apply; namely, that the scheme and host are case-insensitive and therefore should be normalized to lowercase. For example, the URI HTTP://www.EXAMPLE.com/ is equivalent to http://www.example.com/. The other generic syntax components are assumed … Read more

Lucene Query String Elasticsearch “less than or equal to”[URI Search]

You will want to use Query String Syntax (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html) ranges combined with the URI Search (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html) Ranges Ranges can be specified for date, numeric or string fields. Inclusive ranges are specified with square brackets [min TO max] and exclusive ranges with curly brackets {min TO max}. All days in 2012: date:[2012/01/01 TO 2012/12/31] Numbers 1..5 … Read more

Relative URL containing just the querystring

Further research reveals that <a href=”https://stackoverflow.com/questions/15291307/?page=14″>Next</a> is a valid relative URL. It’s documented as part of WHATWG’s URL spec http://url.spec.whatwg.org/#relative-state The new URL will inherit the base URL’s scheme, host, port and path. Tested to work on: Chrome IE 7

Access query string values from Laravel

For future visitors, I use the approach below for > 5.0. It utilizes Laravel’s Request class and can help keep the business logic out of your routes and controller. Example URL admin.website.com/get-grid-value?object=Foo&value=Bar Routes.php Route::get(‘get-grid-value’, ‘YourController@getGridValue’); YourController.php /** * $request is an array of data */ public function getGridValue(Request $request) { // returns “Foo” $object = … Read more

How to use Query Strings for filtering Querysets in Django?

Here is the code: class PassengerList(generics.ListCreateAPIView): model = Passenger serializer_class = PassengerSerializer # Show all of the PASSENGERS in particular WORKSPACE # or all of the PASSENGERS in particular AIRLINE def get_queryset(self): queryset = Passenger.objects.all() workspace = self.request.query_params.get(‘workspace’) airline = self.request.query_params.get(‘airline’) if workspace: queryset = queryset.filter(workspace_id=workspace) elif airline: queryset = queryset.filter(workspace__airline_id=airline) return queryset