Call Realm function from plain old HTTP request

I’m checking this documentation:
Call a Function — MongoDB Realm

However, it’s not clear as to how to call a function from a client not using any SDK and just using plain old HTTP request.

  • What’s the endpoint to call to call a Realm function?

  • What are the required HTTP query parameters and headers?

  • The JSON expression discussed on the documentation is that the actual payload format? And the functions arguments is the JSON array arguments?

In the example function provided:

exports = function(a, b) {
  return a + b;
};

Would the actual payload for the function be like this?:

{
  "numGamesPlayed": {
    "%function": {
      "name": "sum",
      "arguments": [
        10,
        20
      ]
    }
  }
}

Hi @cyberquarks,

To run a function via http call you have to define it as an HTTP 3rd party webhook:

https://docs.mongodb.com/realm/services/configure/service-webhooks/

Let me know if that helps.

Thanks
Pavel

Hi @Pavel_Duchovny,

How does Realm Web SDK call functions? I’m sure it is still bound to what browsers can do, either HTTP or websocket?