1
votes

I am trying to get and delete the data from dynamo db using some 2 primary key column, In which one is reserved keyword timestamp.

When I get data using one of the primary key then it is working fine, But when I trying to delete using two primary key field in projection expression it giving me an error like :

ValidationException: Invalid ProjectionExpression: An expression attribute name used in the document path is not defined; attribute name: #P

And this is my params object

{ TableName: 'Log', ProjectionExpression: 'username, #P', ExpressionAttributeNames: { '#P': 'timestamp' }, ExpressionAttributeValues: null }

username and timestamp are primary key columns.

This thing is not working in only this table. In some others table I have same situation but it will not throwing me this error. Only in this case I am getting the error.

1
So you're making a deleteItem call with a Projection Expression? I don't think that's a legal request, but the error reflected also doesn't align with the real issue. If you are deleting, you have to specify the "Keys" and only Conditional Expressions are allowed in delete requests. - Raymond Lin

1 Answers

0
votes

The DeleteItem API does not allow you to specify a ProjectionExpression. You can get the entire pre-deletion image of the item by selecting ReturnValues = ALL_OLD.