REST syntax not working when filtering data

144 views
Skip to first unread message

Francois Laforge

unread,
Sep 22, 2016, 12:35:19 PM9/22/16
to LoopbackJS
According to the documentation, the REST API uses square brackets for the filter clause:

[where][title]=Test 1234

However, when I try to use this syntax in the API explorer, the results are not filtered:  all the results in the database are returned.  Only when I use the stringified JSON syntax does the explorer return the proper data:

{"where": {"title":"test 1234"}}

Is anyone else having this issue? Should I raise it as a bug?

Strongloop v6.0.2
Loopback v2.34.1 

sim...@ca.ibm.com

unread,
Sep 22, 2016, 7:26:11 PM9/22/16
to LoopbackJS
Yes please raise it as a bug and add a reference to it in this comment. Please provide a sample repo so we can reproduce the issue on our end.

Mark Johnson

unread,
Sep 22, 2016, 10:54:44 PM9/22/16
to LoopbackJS
That's been the case as far as I can remember.

However since it's specific to the Explorer and our team is happy with - and preferring - JSON objects we haven't really seen this as an issue with loopback, rather that the Explorer component is missing a feature.  Being a full JavaScript stack it does make sense to move to passing JSON objects around instead of traditional HTML objects.

sim...@ca.ibm.com

unread,
Sep 22, 2016, 11:02:03 PM9/22/16
to LoopbackJS
Actually I read your question again and as Mark Johnson states, API explorer is designed to only take JSON objects. It sounds like you're requesting a feature to allow input of REST API strings in API explorer?


On Thursday, September 22, 2016 at 9:35:19 AM UTC-7, Francois Laforge wrote:

Francois Laforge

unread,
Sep 23, 2016, 7:43:00 AM9/23/16
to loopb...@googlegroups.com
Thanks for the answers.

I just looked at the "use api explorer" page and saw the note that only stringified JSON can be used with the API explorer.

ALSO, i just found my problem:  me

The API Explorer requires stringified JSON because the word "filter" is the parameter:  
myRestApi.com?filter={where: {{property:value}}

Whereas, when using the REST syntax, the filter + the query is the parameter:
myRestApi.com?filter[where][title]=test

(note the equals sign is not after the word "filter" in the 2nd example, but between the property and the value.

Learned something new today!

sim...@ca.ibm.com

unread,
Sep 23, 2016, 12:42:31 PM9/23/16
to LoopbackJS
Cool, glad you got it resolved.
Reply all
Reply to author
Forward
0 new messages