问题描述
我正在尝试构建一个工作流,其中在第 1 步中我正在运行一个云函数,该函数以 Python 字典的形式返回一个 Json 对象,并且我希望使用 Firestore 连接器将其插入到 Firestore 中。但我收到以下错误:
HTTP server responded with error code 400
in step "create_document",routine "main",line: 27
HTTP server responded with error code 400
in step "create_document",line: 28
{
"body": {
"error": {
"code": 400,"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest","fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"field1\" at 'document.fields[0].value': Cannot find field.","field": "document.fields[0].value"
},{
"description": "Invalid value at 'document.fields[1].value' (type.googleapis.com/google.firestore.v1.Value),200","field": "document.fields[1].value"
},{
"description": "Invalid JSON payload received. Unknown name \"Alt-Svc\" at 'document.fields[2].value': Cannot find field.","field": "document.fields[2].value"
},{
"description": "Invalid JSON payload received. Unknown name \"Cache-Control\" at 'document.fields[2].value': Cannot find field.",{
"description": "Invalid JSON payload received. Unknown name \"Content-Length\" at 'document.fields[2].value': Cannot find field.",{
"description": "Invalid JSON payload received. Unknown name \"Content-Type\" at 'document.fields[2].value': Cannot find field.",{
"description": "Invalid JSON payload received. Unknown name \"Date\" at 'document.fields[2].value': Cannot find field.","field": "document.fields[2].value"
}
这就是我的工作流程的样子
main:
params: [args]
steps:
- step1:
call: http.get
args:
url: https://XXXXXXXXXXXXX.cloudfunctions.net/step1-workflow
query:
bucket_name: ${args.bucket_name}
blob_name: ${args.blob_name}
result: key_val
- step2:
assign:
- project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
- collection: "a-dummy-collection"
- document: "new7-dummy-document"
- create_document:
call: googleapis.firestore.v1.projects.databases.documents.createDocument
args:
collectionId: ${collection}
parent: ${"projects/" + project_id + "/databases/(default)/documents"}
query:
documentId: ${document}
body:
fields: ${key_val}
result: inserted
如果代替 ${key_val} 我使用简单的 json {"field1": {"stringValue": "str1"},"field2": {"integerValue": 10}} 它工作正常并且数据被插入Firestore 但如果我尝试使用变量 ${key_val} 中的对象,该对象与上述 json 的结构相同,则会出错。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)