Greetings-
I have a VERY simple POST that adds a record to a collection. It works in the RQL function editor for the serverless endpoint, yet not in postman:
if (body) {
const reviews = context.services.get("mongodb-atlas").db("myDBName").collection("myCollectionName");
const reviewDoc = {
name: body.name,
user_id: body.user_id,
date: new Date(),
text: body.text,
restaurant_id: BSON.ObjectId(body.restaurant_id)
};
return await reviews.insertOne(reviewDoc);
}
else{
return {};
}
};
HOWEVER, when I try the same POST in postman via JSON object:
{
"text": "test",
"name": "JoeB",
"user_id": "123",
"restaurant_id": "64e3247f8c589fd65db49b50"
}
I get a 400 Bad request and the error “ObjectId in must be a single string of 12 bytes or a string of 24 hex characters.” It seems to have an issue with the “restaurant_id” field which is an ObjectId
Please inform.