【问题标题】:dynamodb UpdateItem using API Gateway as Proxy, errordynamodb UpdateItem 使用 API Gateway 作为代理,错误
【发布时间】:2020-09-21 03:34:33
【问题描述】:

我使用 AWS API Gateway 作为代理来公开 DynamoDB API。 UpdateItem 映射不起作用,它返回:

{
  "__type": "com.amazon.coral.service#SerializationException"
}

下面是映射模板和payload:

{
    "TableName": "registros",
    "Key": {
        "Pk": {
            "S": "$input.path('$.Pk')"
        },
        "Sk": {
            "S": "$input.path('$.Sk')"
            }
    },
    "UpdateExpression": "set intenciones = :intenciones",
    "ConditionExpression": "Pk = :Pk, Sk = :Sk,",
    "ExpressionAttributeValues": {
        ":Pk": {"S": "$input.path('$.Pk')"},
        ":Sk": {"S": "$input.path('$.Sk')"},
        ":intenciones": {"S": "$input.path('$.intenciones')"},
    },
"ReturnValues": "UPDATED_NEW"
}

有效载荷:

{ 
"Pk":"DemandaProd",
"Sk":"raerytre#22",
"intenciones":"news"
}

【问题讨论】:

    标签: amazon-dynamodb aws-api-gateway


    【解决方案1】:

    您不需要ConditionExpression,因为Key 暗示您将匹配PkSk。试试这个:

    {
      "TableName": "registros",
      "Key": {
        "Pk": {
          "S": "$input.path('$.Pk')"
        },
        "Sk": {
          "S": "$input.path('$.Sk')"
        }
      },
      "UpdateExpression": "set intenciones = :intenciones",
      "ExpressionAttributeValues": {
        ":intenciones": { "S": "$input.path('$.intenciones')" }
      },
      "ReturnValues": "UPDATED_NEW"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-19
      相关资源
      最近更新 更多