29952

RESTHeart issue with filters

Question:

I've been using RESTHeart on top of mongodb to have crud support with Mongodb's REST interface. Its working fine when I'm not using any filter, however when I tried to apply filter with the HTTP GET request as provided in the <a href="http://restheart.org/docs/walkthrough.html" rel="nofollow">documentation</a> I got error with the stacktrace as provided below.

Request: http://127.0.0.1:8080/inBeta/donor?filter="{'name':'john'}"

<blockquote>

14:15:49.373 [XNIO-1 task-1] ERROR c.s.restheart.handlers.ErrorHandler - error handling the request java.lang.ClassCastException: java.lang.String cannot be cast to org.bson.BSONObject at com.softinstigate.restheart.db.CollectionDAO.lambda$getCollectionData$45(CollectionDAO.java:178) ~[restheart.jar:0.9.7] at com.softinstigate.restheart.db.CollectionDAO$$Lambda$20/1288164368.accept(Unknown Source) ~[na:na] at java.util.ArrayDeque$DeqSpliterator.forEachRemaining(Unknown Source)~[na:1.8.0_31] at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source) ~[na:1.8.0_31] at com.softinstigate.restheart.db.CollectionDAO.getCollectionData(CollectionDAO.java:177) ~[restheart.jar:0.9.7]

</blockquote>

When I didn't apply any filter its returning JSON object, however with filters its returning BSON object which RESTHeart is unable to convert as JSON response. Will appreciate any help or direction to look into the issue.

P.S. There is no tag for <a href="http://restheart.org/" rel="nofollow">RESTHeart</a>, so it would be helpful if someone could create a tag for the same.

Answer1:

Finally, issue resolved :)

I tried using other APIs provided in documentation and found that everything is working except filter and hence trying out the request using the below request:

http://127.0.0.1:8080/inBeta/donor?filter=%7B'username':'john'%7D

it worked. Hence the culprit is <strong>double quotes</strong> around filter query.

Recommend

  • JHipster, spring rest service with MultiPart and JSON, swagger/curl error
  • Cannot start JBoss from Eclipse
  • Adding Custom Route to Rails app
  • Grabbing just the URL of an href using HTMLAgilityPack
  • AFNetworking send image as file not as data
  • CakePhp 2.6.3 Not Working on PHP 7
  • should I authenticate with every call to RESTHeart?
  • Unable to open phpmyadmin directory: Call to undefined function
  • jQuery more complicated selector vs. each element processing
  • problem with nginx + uwsgi in vhost mode, running django app
  • Yahoo finance historical stock price power query returns 301 response
  • First time running a ASP site, and getting server error in '/' Application
  • Handling exceptions in a class library enveloping a device driver
  • Error building image: Error building rlang - not available on R 3.5.0 (Uploading shiny)
  • Is MVC2 ASP.Net URLDecoding automatically?
  • How to exclude files in a custom clean task?
  • Ant: fileset “dir” attribute with a runtime expanded full path
  • How to retrieve a specific string from a specific list from a file with JSON in Python
  • Rails redirect_to another controller method throwing “Template missing”
  • Rails 3, Custom Actions, and HTML request methods
  • Picasso Taking time to load images
  • get all processes in parallel
  • How to override __call__ in celery on main?
  • Get the last date of each month in a list of dates in Python
  • Haskell: function composition with anonymous/lambda function
  • Main Thread Checker: UI API called on a background thread iOS 11 Xcode 9 GM Seed
  • back button function for phonegap windows phone 7
  • Creating a Multidimensional, Associative Array in VBScript
  • Activation Function choice for Neural network
  • How can I replace the server in Web Component Tester
  • converting text file into xml using php?
  • Unable to get column index with table.getColumn method using custom table Model
  • custom UITableViewCell with image for highlighting
  • Highlight one bar in a series in highcharts?
  • Control modification in presentation layer
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How does Linux kernel interrupt the application?
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass