3rd Party Webhook - POST returns error

I have webhook set up via Realm, utilizing a 3rd Party, http, post.

The url performs as expected.
When I pass a query parameter in the payload from my 3rd party app, it’s logging the following error inside Realm logs, and a 404 from the endpoint calling the webhook.

incoming webhook evaluation blocked by CanEvaluate”

I can see the query parameter being passed over the wire in the logging output provided by Realm.

Here’s the code:

exports = function(payload, response) {
  const reqCollection = "COLLECTION_NAME_HERE"; 
  const query = ({query:payload.query});

  return new Promise((resolve, reject) => {
    const doc = context.services.get("mongodb-atlas").db("DBNAME").collection(reqCollection);
    const data = doc.find(query).toArray()
    .then ((response) => {
      resolve (response); 

Hi @Erin_O_Neill,

Welcome to MongoDB community!

It seems that on your http service or webhook you have placed some code or condition in the can evaluate section

This section cannot be resolved to true therefore you fail.


That’s what I thought as well - it’s empty.
I also attempted an empty object only.

Is the condition set that once you add a configuration, and then remove it, the system inherits the expression, and another function must be created?

Hi @Erin_O_Neill,

Can you share the application link with me?

Have you sure all of your changes are “Reviewed and Deployed”?


Sure thing - I actually figured it out. Want to share this out to everyone - because there’s no examples in the POST of the need for this translation. There’s ref docs for an insert, but use cases for a POST and .find().toArray()…it’s Narnia.

Finally figured it out due to logging.

  • I could see the query object being passed over correctly in the logs (make sure to enable logging on the settings tab)
  • I added the following to the function inside of realm itself, so when I invoked the hook I’d have more information available. Mainly, when passing the query object - why was it failing in the function.
exports = function (payload, response) {
try { console.log('line 1' + EJSON.parse(payload.body))} catch (er) {}
try { console.log('line 2' + JSON.stringify(EJSON.parse(payload.body.text))} catch (er) {}

-this returned line 2 in the Realm logs and upon inspection this is what the body showed (hint - this is not what I sent as the query…or so I thought…)

"base64": "eyJBZGRpdGlvbmFsQXR0cmlidXRlMSI6IkJvbmZpcmUgQ2FubmFiaXMifQ==",
  • Used a base64 from a quick google search and presto - guess what that is - the query
  • the query was failing because it requires a translation for Realm, as the query syntax is { ‘thing1’: ‘query1’} and cannot translate for B64.
    -modifying the ream function to
    const query = EJSON.parse(payload.body.text())

Because this is a .find().toArray() webhook there’s no reason to translate the object back to B64 on the return trip to the endpoint.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.