How to update single object with RESTHeart patch?
Asked Answered
W

1

0

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.

Weever answered 5/1, 2018 at 10:21 Comment(0)
T
0

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

You are missing the document ID in the request URL.

Tritium answered 7/1, 2018 at 8:0 Comment(4)
Thanks for the answer. Now I am getting 200 ok status. But My object is not updating. I am following this syntax, Rh.one('rdb').one('collectionname').patch({ "If-Match": etag }, { 'counter': 15 }, {}).then(Weever
In network I am hitting localhost:8080/_logic/ls/service/risk/rdb/… And give me 200 ok with patchWeever
I'm not sure about what you are trying to do. First the /_logic URI prefix means your are dealing with a custom handler; you have to check if it handles PATCH verb. Second the If-Match is an header used to avoid ghost writes, (see in documentation) but the custom handler should handle it... Can you please better explain what you want to achieve?Tritium
Thanks for the answerWeever

© 2022 - 2024 — McMap. All rights reserved.