1

I have a Firebase project, let's say: project-123. The project has users collection in Firestore database.

I can get all values from users with this API:

GET https://firestore.googleapis.com/v1/projects/project-123/databases/(default)/documents/users

But I want get values based on my filter query. I want get uid from exact email. Based on google, it direct me to these point:

  1. Use :runQuery method
  2. Use structuredQuery at the body

So I tried these: GET https://firestore.googleapis.com/v1/projects/project-123/databases/(default)/documents:runQuery

Payload:

{
    "structuredQuery": {
        "from": [
            {
                "collectionId": "users",
                "allDescendants": true
            }
        ],
        "where": {
            "fieldFilter": {
                "field": {
                    "fieldPath": "email"
                },
                "op": "EQUAL",
                "value": {
                    "stringValue": "[email protected]"
                }
            }
        }
    }
}

But, whatever my payload, the response always:

That’s an error. Your client has issued a malformed or illegal request. That’s all we know.

Anyone got ideas to solve this? I need REST API way because I'm using directus as my backend.

2
  • "Directus is a real-time API and App dashboard for managing SQL database content." makes me wonder why you're using a noSQL database such as Firestore? Commented May 25 at 5:57
  • I only use firestore for FCM. Can you suggest better way to integrate directus with mobile app (I'm using FlutterFlow) for push notifications? Recently I'm using directus, so powerful with flows. But I'm stuck with FCM esp. for Google Oauth2 token T_T Commented May 28 at 6:20

1 Answer 1

1

As I see in your shared code, you're using the wrong HTTP method for the REST API call. According to the official documentation, the runQuery requires a POST request, not a GET:

POST https://firestore.googleapis.com/v1/{parent=projects/*/databases/*/documents}:runQuery

So, change the HTTP method so you can get the correct results.

Sign up to request clarification or add additional context in comments.

1 Comment

OMG! This is correct! Thanks for solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.