Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve this exception: "Cannot specify the AttributesToGet when choosing to get ALL_ATTRIBUTES"?

When I'm trying to scan a dynamoDb table and return specific columns using the following example code from AWS page:

  string tableName = "Thread";
  Table ThreadTable = Table.LoadTable(client, tableName);

  ScanFilter scanFilter = new ScanFilter();
  scanFilter.AddCondition("ForumId", ScanOperator.Equal, forumId);
  scanFilter.AddCondition("Tags", ScanOperator.Contains, "sortkey");

  ScanOperationConfig config = new ScanOperationConfig()
  {
    AttributesToGet = new List<string> { "Subject", "Message" } ,
    Filter = scanFilter
  };

  Search search = ThreadTable.Scan(config); 

I'm getting the following exception:

Message: Amazon.DynamoDBv2.AmazonDynamoDBException : Cannot specify the AttributesToGet when choosing to get ALL_ATTRIBUTES ---- Amazon.Runtime.Internal.HttpErrorResponseException : Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.

How do I solve it?

like image 909
Ronen Festinger Avatar asked Jan 29 '23 22:01

Ronen Festinger


1 Answers

I had to add:

Select = SelectValues.SpecificAttributes

to ScanOperationConfig

like this:

 ScanOperationConfig config = new ScanOperationConfig
 {
   AttributesToGet = new List<string> { "Subject", "Message" } ,
   Filter = scanFilter
   Select = SelectValues.SpecificAttributes
 };
like image 163
Ronen Festinger Avatar answered May 28 '23 11:05

Ronen Festinger