how to pass josn object in publish stream getting -8 errors

+1 vote
while using cmd prompt its working fine in windows platform

 but using rpc it,s getting below errors

{"result":null,"id":null,"error":{"code":-8,"message":"data should be object with single element"}}

{"result":null,"id":null,"error":{"code":-8,"message":"data should be hexadecimal string or recognized object"}}

example code (publish)

String method = "publish";

//creating json object

JSONObject json = new JSONObject();

json.put("userName", "karthik");

List<Object> params = new ArrayList<Object>();

params.add(streamName);

params.add(key);

params.add(json);

 

JSONObject json1 = new JSONObject();

json1.put("chain_name", "testchain");

json1.put("method", method);

json1.put("params", params);

 

the above code written by java
that code is running properly while passing the hexadecimal string but passing json object getting above mention errors
asked Dec 30, 2018 by anonymous

1 Answer

0 votes
This is really a question about Java, but I guess you need to ensure that the JSON object is converted properly when it is included inside the RPC request. Your best bet is to see if you can output the full textual RPC request to some debug log, then compare this to the request shown by the command line and see how they differ.
answered Dec 31, 2018 by MultiChain
...