7

I'm trying to query my Firestore database using an HTTP query via the Insomnia API:

https://firestore.googleapis.com/v1/projects/typebot/databases/(default)/documents/users

with this body:

{
  "structuredQuery": {
    "from": [
        {
            "collectionId": "users"
        }
    ],
    "where": {
        "fieldFilter": {
            "field": {
                "fieldPath": "email"
            },
            "op": "EQUAL",
            "value": {
                "stringValue": "email@test.com"
            }
        }
    }
  }
}

And I get the following error:

HTTP query: Stream error in the HTTP/2 framing layer

Any idea what's wrong?

Louis C
  • 645
  • 5
  • 12
Baptiste Arnaud
  • 2,522
  • 3
  • 25
  • 55

2 Answers2

2

May try to change "GET" to "POST"

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 20 '21 at 20:52
0

I had a similar problem performing a GET request:

GET https://us-central1-my-project-id.cloudfunctions.net/getUsers HTTP/1.1
content-type: application/json
{
        "minAge": "18"
}

against an endpoint defined by this Firestore HTTP Cloud Function:

exports.getUsers = functions.https.onRequest(async (req, res) => {
    // find matching users by age limit.
    const ageLimit = req.body.age;
    ... 
  
});

Turns out, based on this other SO post, that a request body with GET does not have any meaning in the sense that the HTTP spec recommends that the "message-body SHOULD be ignored when handling the request" (presumably, by the server, and that the Firestore server implements this behavior). Oddly, I didn't catch this issue running the exact same function locally with the Functions emulator, so it is likely the local server ignores this recommendation.

To fix the issue, I changed my function to parse the query params instead of a request body:

exports.getUsers = functions.https.onRequest(async (req, res) => {
    // find matching users by age limit.
    const ageLimit = req.query.age; // extract the age as a query param
    ... 
  
});

and the request:

GET https://us-central1-my-project-id.cloudfunctions.net/getUsers?age=18
kip2
  • 6,473
  • 4
  • 55
  • 72