How to create a RESTful URL for search with advanced parameters?

If I need to create a URL in my RESTful web service that my clients will use to search all businesses by their fields, where the fields are optional, what does the URL look like?

A business can be executed by name, name, phone number or name, phone number and contact email address.

+4
source share
1 answer

Chandra, think of a list of all enterprises, such as a set of objects with attributes. You can create URIs that identify (select) a subset using the parameters in the URI.

This is usually done using query string parameters (material after "?"), But you can also specify parameters as path segments or matrix URIs.

The most typical remedy for this would be something like

It is conceptually similar to the select SQL statement.

Parameters in path segments or matrix parameters affect indexing capabilities (for example, matrix parameters allow filtering at several levels, because the hierarchy can continue after operands, which cannot be with query parameters). I suggest you ask another question if you are worried about this.

Example:

http://foo.org/service/businesses/france/name=acme;city=paris/latest/?contact=xxx

Jan

+10
source

Source: https://habr.com/ru/post/1302200/


All Articles