IterableTable & 500/Remaining Input error

A few folks have ran into this 500/Remaining Input error when trying to access an item from an IterableTable. This one stumped me for a bit as well. The issue (for me at least) was not passing the full Value type for the table item.

If you have an IterableTable defined in a struct as:

myTable: IterableTable<K, V> 

the way that table is ultimately stored on chain is:

 myTable: IterableTable {
        inner: Table<K, IterableValue<K, V>>,
        head: Option<K>,
        tail: Option<K>,
}

When you get the handle to the table inner from the REST API, you have to pass the correct Value Type to the API. So, the actual API call would be POST to [fullnodeurl]/tables/{table_handle}/item with a body of:

{
  key_type: K,
  value_type: IterableValue<K, V>,
  key: {whatever}
}

The common error is to try to just pass a body of:

{
  key_type: K,
  value_type: V,
  key: {whatever}
}

for an IterableTable, which returns the 500/Remaining Input error.

So, a valid call would look like POST to https://fullnode.devnet.aptoslabs.com/tables/311148866090171372259007567740078936056/item with body:

{
"key_type": "0xdb3484bf25fc0b8b2fe7f46f454a2120235d6b71f79ef5749695323ffaaf9fbb::Tickets::SeatIdentifier",
"value_type": "0x1::IterableTable::IterableValue<0xdb3484bf25fc0b8b2fe7f46f454a2120235d6b71f79ef5749695323ffaaf9fbb::Tickets::SeatIdentifier,0xdb3484bf25fc0b8b2fe7f46f454a2120235d6b71f79ef5749695323ffaaf9fbb::Tickets::ConcertTicket>",
"key": {"row":"A","seat_number":"26"}
}

You can run the above and see the output (at least until devnet resets next week).

4 Likes