透過 HTTP 要求寫入 Firestore

在工作流程中提出經過驗證的要求,使用 OAuth 2.0 寫入 Firestore。

程式碼範例

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

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽器