我正在使用 Google Firebase 尝试新的 appGyver Composer Pro(没有成功)。AppGyver 使用 REST API 来获取数据库上的数据,但我无法让它工作。数据库非常简单,只有两个文档,所以我使用 SoapUI 和 Postman 来尝试不同的 uri 来确定如何设置 Composer Pro:
因此,使用 GET https://firestore.googleapis.com/v1/projects/{project}/databases/(default)/documents/{collection}/
这是请求的结果:
{"documents": [
{
"name": "projects/{project}/databases/(default)/documents/{collection}/{id}",
"fields": {
"Nombre": {"stringValue": "Cerros"},
"Resolucion": {"mapValue": {"fields": {
"Numero": {"stringValue": "22"},
"Entidad": {"stringValue": "Curaduria"},
"FechaResolucion": {"timestampValue": "2020-04-09T05:00:00Z"}
}}}
},
"createTime": "2020-04-10T13:11:35.364097Z",
"updateTime": "2020-04-10T13:11:35.364097Z"
},
{
"name": "projects/{project}/databases/(default)/documents/{collection}/{id}",
"fields": {
"Nombre": {"stringValue": "Urbanizacion Guayacanes"},
"Resolucion": {"mapValue": {"fields": {
"Numero": {"stringValue": "14"},
"Entidad": {"stringValue": "Municipio de Chinchina"},
"FechaResolucion": {"timestampValue": "2013-11-13T05:00:00Z"}
}}}
},
"createTime": "2020-04-09T14:29:09.633853Z",
"updateTime": "2020-04-09T14:29:09.633853Z"
}
]}
我明白了
{"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"Nombre\": Cannot bind query parameter. Field 'Nombre' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [ {
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [{"description": "Invalid JSON payload received. Unknown name \"Nombre\": Cannot bind query parameter. Field 'Nombre' could not be found in request message."}]
}]
}}
我使用以下任何一种而不是 ?Nombre=Cerros 得到几乎相同的消息(仅字段名称更改):
- ?"Nombre"="Cerros"
- ?"documents.Nombre"="Cerros"
- ?"documents.fields.Nombre"="Cerros"
还是以前用过?以下任何一项:
- :运行查询
- 搜索
我究竟做错了什么?我真的很感激任何帮助
爱德华多
PD 我在 REST API Explorer 上试过:
curl --request POST \
'https://firestore.googleapis.com/v1/projects/permisos-23395/databases/(default)/documents/Inmueble/:runQuery' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"structuredQuery":{"select":{"fields":[{"fieldPath":"Nombre"},{"fieldPath":"matInm"}]},"from":[{"collectionId":"Inmueble","allDescendants":false}],"where":{"fieldFilter":{"field":{"fieldPath":"Nombre"},"op":"EQUAL","value":{"stringValue":"Cerros"}}}}}' \
--compressed
并得到
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document",
"description": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field."
}
]
}
]
}
}