rest api gateway in front of dynamodb gives 404 on GET calls

0

Hi, I am following this guide to create a test REST api gw in front of a dynamo db table.

While the POST call tests work, when I try the GET to retrieve a username I always get a 404


Fri Feb 11 07:17:40 UTC 2022 : Endpoint request URI: https://dynamodb.us-east-1.amazonaws.com/?Action=Query
Fri Feb 11 07:17:40 UTC 2022 : Endpoint request headers: {Authorization=****************************************************************************************************************************************************************************************************************************************************************************************82e823, X-Amz-Date=20220211T071740Z, x-amzn-apigateway-api-id=2xxp28f39k, Accept=application/json, User-Agent=AmazonAPIGateway_2xxp28f39k, X-Amz-Security-Token=xxxxx
Fri Feb 11 07:17:40 UTC 2022 : Endpoint request body after transformations: {
    "TableName": "users",
    "IndexName": "username-index",
    "KeyConditionExpression": "username = :val",
    "ExpressionAttributeValues": {
        ":val": {
            "S": "ABE"
        }
    }
}
Fri Feb 11 07:17:40 UTC 2022 : Sending request to https://dynamodb.us-east-1.amazonaws.com/?Action=Query
Fri Feb 11 07:17:40 UTC 2022 : Received response. Status: 404, Integration latency: 2 ms

this is my GET integration request application/json mapping template


{
    "TableName": "users",
    "IndexName": "username-index",
    "KeyConditionExpression": "username = :val",
    "ExpressionAttributeValues": {
        ":val": {
            "S": "$input.params('username')"
        }
    }
}

If I test the query on dynamodb it works:

aws dynamodb query \
    --table-name $tablename \
    --index-name $indexname \
    --key-condition-expression "username = :v1" \
    --expression-attribute-values file://expression-attributes.json \
    --select ALL_PROJECTED_ATTRIBUTES \
    --return-consumed-capacity INDEXES

where file://expression-attributes.json

{
    ":v1": {"S": "ABE"}
}



gives

{ "Items": [ { "realname": { "S": "xxxxx" }, "username": { "S": "ABE" }, "uid": { "S": "fc1d4fa5-6157-47c7-85a7-3953e477b396" } }

any idea what I am missing?
3回答
1
承認された回答

For the GET method Integration Request, ensure you choose POST for the HTTP method since all DynamoDB Queries are POST.

profile picture
joahna
回答済み 2年前
profile picture
エキスパート
レビュー済み 1ヶ月前
1

From a really quick glance it seems you do not pass the username in to the query string: https://dynamodb.us-east-1.amazonaws.com/?Action=Query

Have you enabled CloudWatch logging on your API GW Endpoint? Should see better information there.

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html

profile pictureAWS
エキスパート
回答済み 2年前
0

Bingo! I needed POST in DynamoDB integration "spasiba"

回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ