Query data on firestore from ApigeeX

Hello,

I would like query data stored in firestore database from ApigeeX, We did this kind of query using ApigeeX on Bigquery, but now we need the same with firestore.

 

 

 

0 3 151
3 REPLIES 3

Hello, 

I could find a way how to do it, here are the main notes:

1. Configure as backend proxy the following api: https://firestore.googleapis.com/v1/projects/PROJECT_ID/databases/(default)/documents:runQuery.

2. In the Target endpoint add the authentication scope: 

 

<Authentication>
  <GoogleAccessToken>
    <Scopes>
      <Scope>https://www.googleapis.com/auth/datastore</Scope>
    </Scopes>
  </GoogleAccessToken>
</Authentication>

 

3. Using Assign Message policy, build the following POST with the query:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage name="queryFirestore">
 <DisplayName>queryFirestore</DisplayName>
 <Set>
  <Verb>POST</Verb>
  <Payload contentType="application/json">
  {
    "structuredQuery": {
     "from": [{
      "collectionId": "COLLECTION_ID",
      "allDescendants": true
     }],

     "where": {
      "fieldFilter": {
       "field": {
        "fieldPath": "FIELD_NAME"
       },
       "op": "EQUAL",
       "value": {
        "stringValue": "FIELD_VALUE",
        }
       }
     }
   }
  }
  </Payload>
 </Set>
 </AssignMessage>

 

 4. Test it.

Hi @nelsonrp24 , glad you were able to find a solution and thanks for sharing.

On the response side you may find this  useful. This shared flow can be used to convert the Firestore data response formats to JSON objects that are ideal to return as response objects of RESTful APIs.

Thanks @markjkelly  I will take a look.