0

使用 Google API Explorer 插入 GCP 的数据存储区时出现以下错误。

我尝试使用其他名称和 ID,但仍然出现错误。我该如何纠正这个问题?

以下是请求正文和错误。

{
    "mode": "Transactional",
    "mutations": [
        {
            "insert": {
                "key": {
                    "path": [
                        {
                            "id": "56294995342131231",
                            "name": "CL-001",
                            "kind": "Log"
                        }
                    ],
                    "partitionId": {
                        "namespaceId": "",
                        "projectId": "triplog-169706"
                    }
                },
                "properties": {
                    "Title": {
                        "stringValue": "Space Needle"
                    },
                    "Longitude": {
                        "doubleValue": 0.00
                    },
                    "Latitude": {
                        "doubleValue": 0.00
                    },
                    "Date": {
                        "timestampValue": "2015-07-03T10:51:50.649Z"
                    },
                    "Rating": {
                        "integerValue": "5"
                    },
                    "Notes": {
                        "stringValue": "Wonderful site to see"
                    }
                }
            }
        }
    ]
}


{
    "error": {
        "code": 400,
        "message": "Invalid value at 'mutations[0].insert.key.path[0]' (oneof), oneof field 'id_type' is already set. Cannot set 'name'",
        "status": "INVALID_ARGUMENT",
        "details": [
            {
                "@type": "type.googleapis.com/google.rpc.BadRequest",
                "fieldViolations": [
                    {
                        "field": "mutations[0].insert.key.path[0]",
                        "description": "Invalid value at 'mutations[0].insert.key.path[0]' (oneof), oneof field 'id_type' is already set. Cannot set 'name'"
                    }
                ]
            }
        ]
    }
}
4

2 回答 2

0

我终于明白了。要获得“交易”,只需运行 beginTransaction API。

发布https://datastore.googleapis.com/v1/projects/ { projectId }:beginTransaction

这将使用一个标识符进行响应,该标识符是一个长字符串。将其用作“交易”的价值。

于 2017-06-20T01:21:56.417 回答
0

根据文档,您似乎应该只在路径元素中设置“名称”或“id”,而不是两者。

https://cloud.google.com/datastore/docs/reference/rest/v1/Key#PathElement

于 2017-06-19T21:59:03.797 回答