prepareunlockspent in C# with RPC

+1 vote
I'm having an issue trying to use prepareunlockspent in c# using rpc.  the JSO that is being sent (before it is byte encoded) looks like:

{\"method\":\"preparelockunspent\",\"params\":[\"'{\\\"asset1\\\":1000}'\"],\"chain_name\":\"test1\",\"chain_key\":null,\"int\":0}

 

But when I issue a GetResponse, I get a 500 internal server error.

Digging deeper the underlying error is :

"{\"result\":null,\"error\":{\"code\":-1,\"message\":\"value is type str, expected real\"},\"id\":null}\n"

 

Any thoughts?

 

Andrew
related to an answer for: preparelockunspent syntax
asked May 19, 2017 by Andrew
edited May 19, 2017

1 Answer

0 votes
When passing the object containing the asset name and quantity in JSON, don't include the single quotes. Those are used in the command line to prevent spaces being treated as a parameter separator, but they're not part of the JSON format itself.
answered May 19, 2017 by MultiChain
Thanks for this.  Unfortunately I can't get this to work.  I have tried every conceivable variation but still no luck!  I have discovered that any command that requires a JSON object fails with the same error.  Do you have a sample JSON string that I could try?  Note, everything works fine at the multichain command line it is only when I send it via RPC using C# that the problem occurs.

Many thanks,

Andrew
If you're connecting to the RPC using C# you need to pass a real JSON object to the MultiChain API, not a string representing that object. You only pass objects as strings on the command line, because multichain-cli converts those strings to objects when calling the MultiChain API. I can't comment on how to do this in C# but that's where you need to get to.
...