BigBug
BigBug

Reputation: 6290

Query Strings in REST

I'd like to have a REST api which contains a GET that allows me to search. I should be able to search by using conditional statements. So for instance

get all items with id 1 and not of colour red. 

How does this get supported in REST? I initially thought that I could allow the user to POST a JSON document outlining what they would like to search for. However, after digging around a bit I realized a GET is probably more appropriate :s. Would the way I approach this is to let the user pass me some sort of a query string which I need to parse?

Thanks in advance...

Upvotes: 0

Views: 70

Answers (1)

arcee123
arcee123

Reputation: 243

In any ajax call, if you choose GET as the style of http request, the data will come in the format of strings in the url. this is what it will look like:

http://example.com/page.php?variable1=data&variable2=data&variable3=data

the server receiving this request is the rest api. you would have to construct it. this is a server-side processing thing. the server-side code will read the data in some form of get call. Then each variable: variable1, variable2, and variable3 in this case, can be referenced.

The api processing should create the json response, and return that to the calling system.

Upvotes: 1

Related Questions