0

i am working with dynamodb to insert and retrieve records from dynamo. please note that when i insert the record to dynamo db it is working fine but when i try to list any item or retrieve any item from dynamodb it return no result found

for retrieving of record

  1. created a iam role which has trust relationship with api gateway. and has managed policies : AmazonAPIGatewayInvokeFullAccess , AmazonDynamoDBFullAccess , APIGatewayAWSProxyExecPolicy , AmazonAPIGatewayAdministrator.

  2. created a table named, emp which has the field ID and name.

  3. created an api gateway named emp, which has resource /employee. and has method post and get. post for insert and get for display record.

  4. for get method selected aws service proxy enter image description here

  5. then in URL Query String Parameters added id in method request.

  6. then also in integration request > URL Query String Parameters added > ID and method.request.querystring.id.

  7. in integration request > body mapping template added application/json and then the json code

    { "TableName": "emp", "KeyConditionExpression": "ID = :v1", "ExpressionAttributeValues": { ":v1": { "S": "$input.params('ID')" } } } then when i tested it it returns no result I cannot figure out why please help.

1
  • Can you please provide a sample data present in the 'emp' table ? Commented Jun 20, 2016 at 15:20

1 Answer 1

4

I'm not an expert on this, but I can see two issues.

First in the DynamoDB service proxy settings the HTTP method needs to be POST, as you are POSTing a request to DynamoDB API, and it has nothing to do with the the fact the you use the GetItem method.

Second, your body mapping template uses KeyconditionExpression that is used in DynamoDB Query API, but not in the GetItem. GetItem needs a Key specified, like here: http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html#API_GetItem_Examples

Hope this helps.

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.