Failed to find document: FunctionError: $in needs an array"

I’m trying to test Atlas Data Api. We’ve enabled the Data Api under App Services/Https Endpoints/Data Api. And we have API KEY configured under authentication. Under IP access list we have 0.0.0.0/0 ALLOWS ACCESS FROM ANYWHERE. But we keep getting response 400: “Failed to find document: FunctionError: $in needs an array”

``curl -s “https://data.mongodb-api.com/app/APP_NAME_HERE/endpoint/data/v1/action/findOne
-X POST
-H “Accept: application/json”
-H “apiKey: MY_KEY_HERE”
-d ‘{
“dataSource”: “mongodb-atlas”,
“database”: “MY_DB_NAME_HERE”,
“collection”: “Place”,
“filter”: {
“title”: “NAME_OF_PLACE”
}
}’`

Are you sure you shared the query that produces the error?

I ask because your query does not use the $in operator. The query you share works for me. It does not return any documents as I have no database named MY_DB_NAME_HERE.

Yes, that’s the weird part I have no “in” operator. But I have always this response 400 Bad Request with “Failed to find document: FunctionError: $in needs an array”. And I double checked all my values appName, apiKey, dbName, nameOfPlace and it seems correct.

Ok found the issue, I just change the permission rules to allow read and write access to this collection. Now it’s returning data, but maybe we need better error messages?

1 Like