HTTP Endpoints and Function Authentication in Mongo Atlas App Service

I have an HTTP Endpoint in mongo Atlas App service name: /movies which is calling a function (moviesfunc) work on a database.
I have Set API Key authentication.
I am trying to add function authentication for type User Id.
In Function settings I am trying to add Authorization function to match the API Key of the user.
I am trying to run the HTTP request in Postman.
I am selecting authentication type as API Key and setting the name and API key same as used in mongo Atlas.
the request gives error {
“error”: “rule not matched for function "moviefunc"”,
“error_code”: “FunctionExecutionError”,} or {
“error”: “cannot compare to undefined”,
“error_code”: “FunctionExecutionError”}

I have tried different Json Expresssions in Function authentication settings like this (Json Expression)
“$and”: [
{ “%%request.authentication.username”: “” },
{ “%%request.authentication.password”: “” }
But I failed. how can I add function level authentication using API Key.
Or authentication using User Id method.

Are you sure you are using the API Key provider from App Services -

This is separate from the Atlas API Key.

rule not matched for function is kind of a poorly worded error, this is actually referring to the can evaluate field on a function, its not referring to rules + roles + filters

I checked that and resolved the issue, i was making wrong function to fetch the query.
thank you for your reply