What is the syntax for an array of keys when using liststreamkeys (multichain 1.0.4)?

+2 votes

liststreamkeys allows the user to "Pass a single key in keys to retrieve information about one key only, pass an array for multiple keys, or * for all keys".

JSON syntax for an array is something like


{"name":"John",
"age":30,
"cars":[ "Ford""BMW""Fiat" ]

}"

 

But when I've tried to pass in an array of keys to search with liststreamkeys, it thinks that I'm passing in the whole thing (curly brackets and all) as the key.

 

testChain: liststreamkeys teststream {"key":"1522317920788t1t63342t3t6tFILE_ACCESStMOD_FlyBase","key":"1522000002801t1t1t1t1tREQ_RESOURCEtMOD_UCSC_Genome_Bioinformatics"}

Here's the output:

[

    {

        "key" : "{key:1522317920788t1t63342t3t6tFILE_ACCESStMOD_FlyBase,key:1522000002801t1t1t1t1tREQ_RESOURCEtMOD_UCSC_Genome_Bioinformatics}",

        "items" : 0,

        "confirmed" : 0

    }

]

I've also tried 

testChain: liststreamkeys teststream ["1522317920788t1t63342t3t6tFILE_ACCESStMOD_FlyBase","1522000002801t1t1t1t1tREQ_RESOURCEtMOD_UCSC_Genome_Bioinformatics"]

related to an answer for: Can read multiple keys of a stream?
asked Jul 27, 2018 by M.Green
Postman request:
POST  HTTP/1.1
Host: <multichainrpc><password><your_ip_address>:<port>
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: a56aa390-3f32-9a4b-d780-96c6fef22e04

{
    "jsonrpc":"1.0",
    "id":"testchain",
    "method":"liststreamqueryitems",
    "params": ["Demo", {"keys":["key1", "key2"]}]
}

1 Answer

+2 votes
 
Best answer

When using the command line you need to put single quotes around JSON array/object parameters:

liststreamkeys teststream '["key1","key2","key3"]'

This is just related to the command line and is not true if you use the JSON-RPC API directly.

answered Jul 30, 2018 by MultiChain
selected Jul 30, 2018 by M.Green
Thank you, this worked perfectly!
...