Use of the REST question mark

Asked

Viewed 286 times

1

I have a list of values on screen that as the user type will be filtered the options. If the user wishes to view all the records he will type: ?;

Then my Rest call will be: meuservidor/buscar/?

From what I understand, this "?" is interpreted as the beginning of the statement of variables, but I wanted to capture the "?" to know if I must return all records.

My question is whether I can send just the question mark in some way or I would have to replace and send a "*" maybe..

2 answers

1

It is possible to use the "?" in the URL, but you would have to replace it with its encoding: %3F. In that case, your URL would be:

meuservidor/buscar/%3F

Similar behavior is adopted when the URL has whitespace.

1


If you really want to follow the specification REST, a request GET no parameters for the endpoint shall result in the return of all records.

meuservidor/buscar

Will result in the full list.

Let’s say one element of your quest is the collection Animal. You can return the element as part of the path:

meuservidor/buscar/animal

But if you want to pass search parameters (not an element specification), use querystring (literally question string):

meuservidor/buscar?nome=gato

To return all records whose property nome be equal to gato, or

meuservidor/buscar/animal?nome=gato

To return all records from the collection animal whose property nome be equal to gato.

  • Cool.. In fact it’s better this way, I who had complicated and did not think by simple.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.