AWS DynamoDBからデータ取得

Dynamoからデータ取得する際に少し詰まった。

 

原因としては、値をString型にする必要があるということだった。

 

 

Client error: `POST https://dynamodb.ap-northeast-1.amazonaws.com` resulted in a `400 Bad Request` response:
{\"__type\":\"com.amazon.coral.service#SerializationException\",\"Message\":\"NUMBER_VALUE cannot be converted to String\"}

 

DynamoDBには数値型で入れてあり、取得する際もこうしてある。

array( 'N' => $xxxxxxxx )

 

この $xxxxxxxx の部分をint型ではなく、String型にしなければならない。

strval( $xxxxxxxx )で解決。

 

 

https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/Programming.Errors.html

 

Dynamoではないが、参考情報

https://docs.aws.amazon.com/ja_jp/amazonglacier/latest/dev/api-error-responses.html

SerializationException リクエストの本文が無効になっている場合に返されます。JSON ペイロードが含まれる場合には、正しい形式になっていることを確認します。 400 Bad Request