strongloop/loopback-component-explorer

Filter on level 2 properties does not work

mike-aungsan opened this issue · 2 comments

curl -X GET --header "Accept: application/json" "http://localhost/api/userIdentities/findOne?filter=%5Bwhere%5D%5Bprofile.username%5D%3Dtest%40gmail.com&access_token=d5qc43SEUrxi3WnFBBgMapuyP27lsb20IMD3lqhxmAqJkDLafI2z2eG5hIcu0ySQ&access_token=d5qc43SEUrxi3WnFBBgMapuyP27lsb20IMD3lqhxmAqJkDLafI2z2eG5hIcu0ySQ"

Request URL
http://localhost/api/userIdentities/findOne?filter=%5Bwhere%5D%5Bprofile.username%5D%3Dtest%40gmail.com&access_token=d5qc43SEUrxi3WnFBBgMapuyP27lsb20IMD3lqhxmAqJkDLafI2z2eG5hIcu0ySQ

{
  "error": {
    "name": "Error",
    "status": 400,
    "message": "invalid value for argument 'filter' of type 'object': [where][profile.username]=test@gmail.com. Received type was string. Error: Unexpected token w",
    "statusCode": 400,
    "stack": "Error: invalid value for argument 'filter' of type 'object': [where][profile.username]=test@gmail.com. Received type was string. Error: Unexpected token w\n    at new badArgumentError (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/shared-method.js:268:13)\n    at coerceAccepts (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/shared-method.js:324:13)\n    at SharedMethod.invoke (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/shared-method.js:217:16)\n    at HttpContext.invoke (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/http-context.js:384:12)\n    at /home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:620:11\n    at execStack (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:460:7)\n    at RemoteObjects.execHooks (/home/project_report/dev/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:464:10)\n    at /home/test/dev/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:617:10\n    at /home/test/dev/node_modules/loopback/lib/application.js:357:13\n    at /home/test/dev/node_modules/loopback/lib/model.js:313:7"
  }
}

It is explorer issue. It work from browser.

Ref: strongloop/loopback#517

Closing as dup of strongloop/loopback#517

I don't think it is a duplicate... Explore is adding a "=" after the filter.

... /findOne?filter**=**%5Bwhere%5D%5Bprofile.username ...

If you remove the = then the query works.