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.
“Error:
incoming webhook evaluation blocked by CanEvaluate”
I can see the query parameter being passed over the wire in the logging output provided by Realm.
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.
-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…)
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.