0
votes

Im trying to set my API Gateway to from DynamoDB but I keep getting this error:

Endpoint response body before transformations: {"__type":"com.amazon.coral.validate#ValidationException","message":"Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."}

I tried different Mapping templates but nothing..

My table is called : datasales and has three columns country, region, dep and name. with country is the primary key.

everything is set and when I test results I get an empty json.

can someone tell me how to create the right application/json for this table ?

1
Are you using VTL ? Can you show us your code doing the request ? - BTL
{ "TableName": "sales", "IndexName": "sales-index" "KeyConditionExpression": "country = :val", "ExpressionAttributeValues": { ":val": { "S": "$input.params('sales')" } } } - habdie
@BTL check my comment above please - habdie

1 Answers

0
votes

First of all you should check the AWS DynamoDB doc.

What do you want to do ? A query, a getItem ?

Here is the template if you want to get one item :

{
    "TableName": "datasales",
    "Key": {
        "country": {
            "S": "$input.params('country')"
        }
    }
}

And here is the doc : https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html


If you want to do a query :

{
    "TableName": "datasales",
    "KeyConditionExpression": "country = :c",
    "ExpressionAttributeValues": {
      ":c": { "S": "$input.params('country')" }
    }
}

And here is the doc : https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html