Firestore HTTP Insomnia 查询:HTTP/2 帧层中的流错误

Bap*_*aud 6 firebase google-cloud-firestore insomnia

我正在尝试通过 Insomnia API 使用 HTTP 查询来查询我的 Firestore 数据库:

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

用这个身体:

{
  "structuredQuery": {
    "from": [
        {
            "collectionId": "users"
        }
    ],
    "where": {
        "fieldFilter": {
            "field": {
                "fieldPath": "email"
            },
            "op": "EQUAL",
            "value": {
                "stringValue": "email@test.com"
            }
        }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

HTTP 查询:HTTP/2 帧层中的流错误

知道出了什么问题吗?

kip*_*ip2 0

我在执行请求时遇到了类似的问题GET

GET https://us-central1-my-project-id.cloudfunctions.net/getUsers HTTP/1.1
content-type: application/json
{
        "minAge": "18"
}
Run Code Online (Sandbox Code Playgroud)

针对此 Firestore HTTP 云函数定义的端点:

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

事实证明,基于另一篇 SO post,请求正文GET没有任何意义,因为 HTTP 规范建议“处理请求时应该忽略消息正文”(大概是由服务器,并且Firestore 服务器实现了此行为)。奇怪的是,我没有在使用 Functions 模拟器在本地运行完全相同的函数时发现此问题,因此本地服务器可能会忽略此建议。

为了解决这个问题,我更改了函数来解析查询参数而不是请求正文:

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
    ... 
  
});
Run Code Online (Sandbox Code Playgroud)

和请求:

GET https://us-central1-my-project-id.cloudfunctions.net/getUsers?age=18
Run Code Online (Sandbox Code Playgroud)