How to pass a parameter to Realm function from Https Endpoints

I have a Realm function that using the testing console is invoked as exports({“userId”: “638cea4bd157479ec554d9b9”}). Within the function I get the object id as

data.userId and the function works as expected.

Now if I expose the Realm function as an Https Endpoint how would I specify this?

-H “Content-Type: application/json”
-d ‘{“userId”: “638cea4bd157479ec554d9b9”}’

returns an error:

{“error”:“{"message":"ObjectId in must be a single string of 12 bytes or a string of 24 hex characters","name":"Error"}”,“error_code”:“FunctionExecutionError”,“link”:“App Services”}%

The value is null because it isn’t being passed to REALM

OK. I figured it out:

From curl:

curl \
-H "Content-Type: application/json" \
-d '{"query": {"userId": "63dcd7a0766580205fe7869d"}}' \

Wiithin the function:

exports = async function(request, response){
  console.log( "Request: " + JSON.stringify(request))
 const body = JSON.parse(request.body.text());
 const userId = body.query.userId;

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