SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

How to work Patch in RestHeart and MongoDB? #136

Closed brahmi434 closed 8 years ago

brahmi434 commented 8 years ago

Hi,

I am using Patch Method and using mongodb version 2.4.5 and restHeart version 2.0.. Json Data:{"$set":{"IsActive": "1"}} and Mention "Oid" and "etagId"

But I get 500 error like below

500 Internal Server Error",
  "message": "Command failed with error 10148: 'exception: Mod on _id not allowed' on server Localhost:27017 The full response is { 'value' : { '_id' : { '$oid' : '574fb5004bb44852736b52f7' }, 'Batch' : [{ 'BatchName' : 'June 05, 2016 - June 12, 2016', 'Venue' : 'Phase1: 05 - 12 Jun, 2016 ISB, Hyderabad Campus; Phase2: 25 - 30 Sep, 2016 ISB, Mohali Campus' }, { 'BatchName' : 'November 04, 2016 - November 11, 2016', 'Venue' : 'Phase1: 04 - 11 Nov, 2016 ISB, Hyderabad Campus; Phase2: 05 - 11 Feb, 2017 ISB, Mohali Campus' }], 'Quiz' : [{ 'Question1' : 'Informal negotiation involves:', 'Choice' : ['any number of people', 'three people', 'two people', 'four people'], 'Ans' : 'two people' }], 'WhoShouldAttend' : [{ 'Description' : 'This programme is suited for senior managers who want to enhance their negotiation skills. The programme is recommended specifically for the following profiles', 'TypeOfPersons' : ['Group Managers', 'Business Managers', 'Functional Managers'] }], 'FoodPlan' : [{ 'ItemName' : 'Mixed Veg Curry', 'Description' : ' mix veg recipe for chapati', 'IsSpicy' : '1', 'IsSalt' : '0', 'IsSugar' : '0', 'Image' : '', 'IsActive' : '1' }], 'CreatedBy' : '574fb5004bb44852736b52f7', 'CreatedOn' : '12-02-2013', 'DocAttachments' : [], 'IsActive' : '1', 'KeyBenefits' : 'Prepare to take on broader responsibilities that require leading outside your area of expertise', 'ModifiedBy' : '574849babcb7a1530920df49', 'ModifiedOn' : '10-06-2016', 'Overview' : 'When you aspire to move from a specialist role as a manager or a functional expert to general management role you realise that you need an altogether new set of skill sets that can help you to accelerate your transition. ', 'ProgramEndDate' : '10-Sep-2016', 'ProgramImageURL' : '..assets/images', 'ProgramName' : 'Accelerated Management Programme', 'ProgramStartDate' : '12-Aug-2016', 'Attachements' : '', 'IsAttend' : '1', 'Comments' : 'iam Attend', 'TypeOfProgram' : '', '_etag' : { '$oid' : '574ecbf872a1533eb18d551d' } }, 'errmsg' : 'exception: Mod on _id not allowed', 'code' : 10148, 'ok' : 0.0 }"
}
ujibang commented 8 years ago

Please report the full request including the URL

ujibang commented 8 years ago

I suspect your request is something like

PATCH /db/coll/docid {"_id": "different_docid", .... }

in this case you get that error from MongoDB since you are trying to modify the _id property of the existing document with _id="docid"

ujibang commented 8 years ago

closing for now, if you have more info feel free to reopen