JavaScript SDK - DynamoDB - Error - "Unexpected key 'KeyConditionExpression' found in params"

0

I'm trying to query a DynamoDB table using the JavaScript SDK from my backend, but I'm receiving the following error:

Error UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params

I'm not sure what the issue is as I've checked the syntax multiple times. The few anwers found online did not help.

My code:

const dynamoDB = new AWS.DynamoDB();

const params = {
    TableName: tableName,
    KeyConditionExpression: `#P = :projectname`,
    ExpressionAttributeNames: {
      "#P": "project",
      "#B": "bucket"
    },
    ExpressionAttributeValues: {
      ":projectname": {
        S: "projectName",
      },
      ":bucket": {
        S: "bucketName"
      }
    },
    FilterExpression: "#B = :bucket",
  };

const response = await dynamoDB.query(params).promise();
return response

Has anybody had this issue before?

asked a year ago338 views
1 Answer
-1

Error UnexpectedParameter: Unexpected key 'KeyConditionExpression' found in params

`#P = :projectname`,

This issue is due to the single quotes.

Please remove that type it manually after pasting the code in the target place.

'#P = :projectname',

It should look like the above.

If this answer has led to a solution, please approve the answer for the betterment of the community.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions