Best answer

Firebase structured query error in json


Userlevel 1

I have continued without success  to try and test the trigger which connect to my firestore.

I want to trigger when a new document is added to a collection. here is the code:

{
"select":
{
"fields": [
{
"measureRef"
}
]
},
"from": [
{
"CompletedMeasures
}
]
}

I keep getting this error

Failed to fetch a record from Firebase / Firestore
Error while retrieving: The specified query does not contain valid JSON. Unexpected token } in JSON at position 65

I have added/removed the braces but not joy.. Help please what’s wrong??

icon

Best answer by GetUWired 16 May 2022, 15:22

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +11

Hi @myfitter 
That is not valid JSON. 

Objects (curly brackets) should have valid key & value pairs. i.e {key: value}. Your objects just have values.  Structured query docs are here: https://firebase.google.com/docs/firestore/reference/rest/v1beta1/StructuredQuery

{

"select": {

    "fields": [
      {

       "fieldPath": "measureRef" 
  }  

  ]

},

"from": [

{

"collectionId": string,

"allDescendants": boolean

}

]

}

 

FROM DOCUMENTS: https://firebase.google.com/docs/firestore/reference/rest/v1beta1/StructuredQuery#CollectionSelector

Userlevel 1

Thanks for taking the time to respond.

Still finding my way round JSON - starting to understand it better now - that helps a lot thank you!!