0
votes

My code:

def query_consulta_token(holder_id) dynamodb = Aws::DynamoDB::Client.new

table_name = "pix_owner_confirmation_token"

holder_id = holder_id

params = {
  table_name: table_name,
  key: {
    holder_id: holder_id,
  },
}

begin
  result = dynamodb.get_item(params)
  puts "%s - %s",
       result.item["holder_id"],
       result.item["address"],
       result.item["token"]
rescue Aws::DynamoDB::Errors::ServiceError => error
  puts "Unable to read item:"
  puts "#{error.message}"
  binding.pry
end

end

My result: Unable to read item: The provided key element does not match the schema

1
How is your table primary key defined?Seth Geoghegan
Chave de partição primária: token (String)William Albuquerque da Silva

1 Answers

0
votes

The parameters you sent to get_item specifies a primary key named holder_id:

params = {
  table_name: table_name,
  key: {
    holder_id: holder_id,
  }
}

However, you've commented that your table has a primary key named token. To fix this, you need to provide the name of your primary key in your params:

params = {
  table_name: table_name,
  key: {
    token:<your token here>,
  }
}