Using the REST question mark

1

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

Then my rest call will be: myserver / fetch /?

From what I understand, this "?" is interpreted as the beginning of the variable declaration, however I wanted to capture the "?" to see if I should return all records.

My question is if I have to just send the question mark somehow or I would have to give a replace and send a "*" maybe ..

    
asked by anonymous 01.03.2017 / 13:00

2 answers

1

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

meuservidor/buscar

It will result in the complete list.

Let's say that one element of your search is the collection Animal . You can then 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 nome q property is equal to gato , or

meuservidor/buscar/animal?nome=gato

To return all records in the animal collection whose nome property is equal to gato .

    
01.03.2017 / 15:06
1

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

meuservidor/buscar/%3F

Similar behavior is adopted when the URL has spaces.

    
01.03.2017 / 14:47