javascriptmongodbrestrestheart

How to update single object with RESTHeart patch?


I am using RESTHeart and MongoDB. I have multiple JSON objects and I want to update a particular object at a time with a REST call. I am following https://softinstigate.atlassian.net/wiki/spaces/RH/pages/9207882/Reference+sheet , But I am not able to update my object. patch call is not give me 200 ok status.

I am able to use patch, but I am not able to find out a particular object for the update.

Rh.one('db')
  .one('api')
  .patch(counter, {}, {})
  .then(function(response){

});

When I try some condition if-match in curly braces then I get this error:

412 (Precondition Failed) LIKE

Rh.one('db')
  .one('api')
  .patch(counter, {}, {"If-Match": index.name})
  .then(function(response){

});

I want to update particular object with patch.


Solution

  • To update a document the URI needs to be /db/coll/<docid>

    You are missing the document ID in the request URL.