0

I am trying to update a key in the MongoDB document using RESTHear api but the value is not getting updated, however, I am getting 200 OK.

I tried PATCH and PUT both. Below are the URIs I tried.

http PUT "http://localhost:8080/presence/active_watchers?filter={'presentity_uri':'sip:service-1@opensipstest.org'}" event_id=12

http PATCH "http://localhost:8080/presence/active_watchers?filter={'presentity_uri':'sip:service-1@opensipstest.org'}" event_id=12

Both the time I got 200 OK response but the value didn't update.

Am I doing something wrong. I couldn't find any example for this.

I am using Restheart v 2.0.0 Beta.

Jardanian
  • 711
  • 1
  • 6
  • 11

1 Answers1

2

To bulk update documents matching a filter expression do http PATCH "http://localhost:8080/presence/active_watchers/*?filter={'presentity_uri':'sip:service-1@opensipstest.org'}" event_id=12

If you PUT/PATCH the URI /presence/active_watchers you actually update the collection properties (in RESTHeart dbs and collections have their own properties).

To update documents, you need to provide a document URI /db/coll/docid and for bulk updates you can use the wildcard /db/coll/*?filter=[filter expression]

See Resource URI in the documentation form more information.

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • Could see this problem https://stackoverflow.com/questions/48111526/how-to-update-single-object-with-restheart-patch. – Varun Sharma Jan 07 '18 at 06:56