1

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 ?

3
  • Are you using VTL ? Can you show us your code doing the request ? Commented Apr 16, 2020 at 17:31
  • { "TableName": "sales", "IndexName": "sales-index" "KeyConditionExpression": "country = :val", "ExpressionAttributeValues": { ":val": { "S": "$input.params('sales')" } } } Commented Apr 16, 2020 at 17:34
  • @BTL check my comment above please Commented Apr 16, 2020 at 17:34

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.