1
votes

Both the hash and range are specified, yet it thinks one is empty? Or is it talking about some other attribute?

The task.result() that is returned is nil, and task.error() says:

"Error Domain=com.amazonaws.AWSDynamoDBErrorDomain Code=0 "Supplied AttributeValue is empty, must contain exactly one of the supported datatypes" UserInfo=0x7ff3c0e21d40 {NSLocalizedDescription=Supplied AttributeValue is empty, must contain exactly one of the supported datatypes}"

I am sure that the hash and range names are correct, and so is the table name.

Writing in Swift, here is my code:

var venueIdAttribute = AWSDynamoDBAttributeValue()
venueIdAttribute.N = "2164156"

var venueIdCondition = AWSDynamoDBCondition()
venueIdCondition.comparisonOperator = .EQ // Hash Key must always be Equals
venueIdCondition.attributeValueList = [venueIdAttribute]

var startDateAttribute = AWSDynamoDBAttributeValue()
var startString = String(format:"%1.0f", lastSyncDate.timeIntervalSince1970 * 1000)
startDateAttribute.N = String(format:"%1.0f", lastSyncDate.timeIntervalSince1970 * 1000)

var dateCondition = AWSDynamoDBCondition()
dateCondition.comparisonOperator = .GT
dateCondition.attributeValueList = [startDateAttribute];

var keysArray : NSArray = [["venueId" : venueIdCondition, "dateInterval" : dateCondition]]
var keysAndAttributes : AWSDynamoDBKeysAndAttributes = AWSDynamoDBKeysAndAttributes()
keysAndAttributes.keys = keysArray;

var requestMap : NSDictionary = ["myTableName":keysAndAttributes]

var request : AWSDynamoDBBatchGetItemInput = AWSDynamoDBBatchGetItemInput()
request.requestItems = requestMap

var response : BFTask = dynamoDB.batchGetItem(request)  // This is synchronous
1

1 Answers

3
votes

keysArray is not formatted correctly in the code snippet. You are creating a NSString : AWSDynamoDBCondition dictionary, but it needs to be NSString : AWSDynamoDBAttributeValue dictionary. The following reference may help understand how to format the BatchGetItem request.