2017-09-28 15 views
0

AWSサービスプロキシを使用して、DynamoDBをAPIとして公開しています。 PutItemではうまくいきますが、のの配列を更新する方法がわかりません。 "paymentDetail"以下はMapのリストです。私はDynamoDBに投稿できますが、JSONペイロードの更新に失敗しました。dynamodb UpdateItem jsonペイロード

{ "__type": "com.amazon.coral.service番号のSerializationException"}

は、誰もがどのようにあなたのアイデアを共有することができわからないDynamoDBのこれをサポートかどうか、私はいつも、このメッセージが表示されましたマッピング・テンプレートを使用してJSONペイロードを更新しますか?前もって感謝します。

ここに私のコードです、助けてください。情報が十分でない場合は親切に教えてください。 UpdateItemため

---------リクエストメソッド------------

{ 
    "TableName": "claim", 
    "Key": { 
     "claimNumber": { 
      "S": "$input.params("claimNumber")" 
     } 
    }, 
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt", 
    "ConditionExpression": "claimNumber = :claimNumber", 
    "ExpressionAttributeValues": { 
     ":claimNumber": {"S": "$input.params("claimNumber")"}, 
     ":claimStatus": {"S": "$input.path("$.claimStatus")"}, 
     ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"}, 
     ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"}, 
     ":paymentDetail": {"L": "$input.path("$.paymentDetail")"}, 
     ":updatedAt": {"S": "$input.path("$.updatedAt")"} 
}, 
"ReturnValues": "UPDATED_NEW" 

}

------ UpdateItem用----テストデータ---------

{ 
    "claimNumber": "000-00-000959", 
    "updatedAt":"2017-09-10", 
    "claimStatus": "close", 
    "statusUpdateDate": "2017-09-13", 
    "netClaimAmount": 60000000, 
    "paymentDetail": [ 
     { 
      "coverage": "AAA", 
      "claimPaymentDate": "2017-09-03", 
      "claimAmount": "10000000", 
      "costCategory": "1", 
      "costType": "A" 
     }, 
     { 
      "coverage": "BBB", 
      "claimPaymentDate": "2017-09-03", 
      "claimAmount": "20000000", 
      "costCategory": "2", 
      "costType": "B" 
     }, 
     { 
      "coverage": "CCC", 
      "claimPaymentDate": "2017-09-03", 
      "claimAmount": "30000000", 
      "costCategory": "3", 
      "costType": "C" 
     } 
    ] 
} 

---あなたの情報についてPutItem ---

#set($inputRoot = $input.path('$')) 
{ 
    "TableName": "claim", 
    "Item": { 
     "claimNumber": { 
      "S": "$input.path("$.claimNumber")" 
     }, 
     "policyNumber": { 
      "S": "$input.path("$.policyNumber")" 
     }, 
     "productName": { 
      "S": "$input.path("$.productName")" 
     }, 
     "lossDate": { 
      "S": "$input.path("$.lossDate")" 
     }, 
     "lossTime": { 
      "S": "$input.path("$.lossTime")" 
     }, 
     "reportedDate": { 
      "S": "$input.path("$.reportedDate")" 
     }, 
     "lossCause": { 
      "S": "$input.path("$.lossCause")" 
     }, 
     "description": { 
      "S": "$input.path("$.description")" 
     }, 
     "prefectureCode": { 
      "S": "$input.path("$.prefectureCode")" 
     }, 
     "city": { 
      "S": "$input.path("$.city")" 
     }, 
     "address": { 
      "S": "$input.path("$.address")" 
     }, 
     "reportedByType": { 
      "S": "$input.path("$.reportedByType")" 
     }, 
     "createdAt": { 
      "S": "$input.path("$.createdAt")" 
     }, 
     "updatedAt": { 
      "S": "$input.path("$.updatedAt")" 
     }, 
     "claimImageId": { 
      "S": "$input.path("$.claimImageId")" 
     }, 
     "contact": { 
      "M": { 
       "lastName": { 
        "S": "$input.path("$.contact.lastName")" 
       }, 
       "firstName": { 
        "S": "$input.path("$.contact.firstName")" 
       }, 
       "postCode": { 
        "S": "$input.path("$.contact.postCode")" 
       }, 
       "prefectureCode": { 
        "S": "$input.path("$.contact.prefectureCode")" 
       }, 
       "city": { 
        "S": "$input.path("$.contact.city")" 
       }, 
       "address": { 
        "S": "$input.path("$.contact.address")" 
       }, 
       "homePhone": { 
        "S": "$input.path("$.contact.homePhone")" 
       }, 
       "email": { 
        "S": "$input.path("$.contact.email")" 
       } 
      } 
     }, 
     "claimStatus": { 
      "S": "$input.path("$.claimStatus")" 
     }, 
     "statusUpdateDate": { 
      "S": "$input.path("$.statusUpdateDate")" 
     }, 
     "netClaimAmount": { 
      "N": "$input.path("$.netClaimAmount")" 
     }, 
     "paymentDetail": { 
      "L":[ 
       #foreach($elem in $inputRoot.paymentDetail){ 
         "M": { 
          "coverage": { 
           "S": "$elem.coverage" 
          }, 
          "claimPaymentDate": { 
           "S": "$elem.claimPaymentDate" 
          }, 
          "claimAmount": { 
           "S": "$elem.claimAmount" 
          }, 
          "costCategory": { 
           "S": "$elem.costCategory" 
          }, 
          "costType": { 
           "S": "$elem.costType" 
          } 
         } 
       }#if($foreach.hasNext),#end 
       #end 
      ] 
     } 
    } 
} 

答えて

1

身体マッピングテンプレートに問題があるようです。 下記をご覧ください。

#set($inputRoot = $input.path('$')) 
{ 
    "TableName": "claim", 
    "Key": { 
     "claimNumber": { 
      "S": "$input.path("$.claimNumber")" 
     } 
    }, 
    "UpdateExpression": "set claimStatus = :claimStatus, statusUpdateDate = :statusUpdateDate, netClaimAmount = :netClaimAmount, paymentDetail = :paymentDetail, updatedAt = :updatedAt", 
    "ConditionExpression": "claimNumber = :claimNumber", 
    "ExpressionAttributeValues": { 
     ":claimNumber": {"S": "$input.path("$.claimNumber")"}, 
     ":claimStatus": {"S": "$input.path("$.claimStatus")"}, 
     ":statusUpdateDate": {"S": "$input.path("$.statusUpdateDate")"}, 
     ":netClaimAmount": {"N": "$input.path("$.netClaimAmount")"}, 
       ":updatedAt": {"S": "$input.path("$.updatedAt")"}, 
     ":paymentDetail": { 
      "L":[ 
       #foreach($elem in $inputRoot.paymentDetail){ 
         "M": { 
          "coverage": { 
           "S": "$elem.coverage" 
          }, 
          "claimPaymentDate": { 
           "S": "$elem.claimPaymentDate" 
          }, 
          "claimAmount": { 
           "S": "$elem.claimAmount" 
          }, 
          "costCategory": { 
           "S": "$elem.costCategory" 
          }, 
          "costType": { 
           "S": "$elem.costType" 
          } 
         } 
       }#if($foreach.hasNext),#end 
       #end 
      ] 
     } 
    }, 
"ReturnValues": "UPDATED_NEW" 
} 
関連する問題