Write to Firestore through an HTTP request

Makes an authenticated request within a workflow, using OAuth 2.0 to write to Firestore.

Code sample

YAML

- initialize:
    assign:
      - project: "myproject123"
      - collection: "myEntries"
      - document: "Visits"
- write_item:
    call: http.request
    args:
      url: ${"https://firestore.googleapis.com/v1/projects/"+project+"/databases/(default)/documents/"+collection+"/"+document}
      auth:
        type: OAuth2
      method: PATCH
      body:
        name: ${"projects/"+project+"/databases/(default)/documents/"+collection+"/"+document}
        fields:
          Counter:
            integerValue: 7

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.