C# RPC API Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

+5 votes
I am trying to build an application with LucidOcean C# API, in the command line the mulitichain node is active.

I am not sure if I am doing it in the right way, I create a C# applicationi and try to connect to this multichain node by using methods from API.

Here is my code,

 MultiChainConnection connection = new MultiChainConnection()
            {
                Hostname = "127.0.0.1",
                Port = 4336,
                Username = "multichainrpc",
                Password = "password",
                ChainName = "chain1",
                BurnAddress = "1XXXXXXXZXXXXXXXZMXXXXXXXqXXXXXXbYgmzH",
                RootNodeAddress = "1TXfbuQzKGpDbTsAEAxdi7ZK5aUYTEVicUKWYT"
            };
            _Client = new MultiChainClient(connection);

...

...

     public JsonRpcResponse<List<string>> GetAddressesAsync()
        {
            JsonRpcResponse<List<string>> response = null;
            Task.Run(async () =>
            {
                response = await _Client.Wallet.GetAddressesAsync();
            }).GetAwaiter().GetResult();

            ResponseLogger<List<string>>.Log(response);

            return response;
        }

 

...

...

 

First question is, am I doing it in a right way?

2nd, How do I know if RPC is connected to the node?

3rd,  how to solve "Unexpected character encountered while parsing value: <. Path '', line 0, position 0."

 

Thanks a lot if anybody could help me a little.
asked Sep 12, 2017 by Steven
We recommend reaching out to the LucidOcean guys directly and asking them to answer here, since the workings of third party libraries built for MultiChain is beyond our scope.

1 Answer

+2 votes
  1. In the *MultiChainConnection* you need to change the details to what your chain details are in the multichain.conf in your appdata directory. The ip address is where you are connecting to your node, in your case its localhost but the node is not running on that ip address, that needs to be your physical IP on your local area network.
  2. You would run multichaind <chainname> -daemon and then this would show you a msg:
    1. MultiChain 1.0 Daemon (protocol 10008)

      Other nodes can connect to this node using:
      multichaind <chain>@<your local ip>:<default-network-port>

      Node started

      This means your node is started and can accept RPC requests.
  3. As for calling the API, In your case you are calling 'GetAddresses' you would call it with the following call:
    1. MultiChainClient _Client = new MultiChainClient(connection);
      response = _Client.Wallet.GetNewAddress();
    2. When you stop the debugger on response, you will get the entire JSON object that is returned from the JSON RPC api.
      
  4. For ports and params consult your params.dat in your appdata/multichain folder.
answered Sep 13, 2017 by RobertJ
Your issue is also addressed here. https://github.com/LucidOcean/multichain/issues/1
Thanks for your reply here and on github, that really helped me a lot!
https://github.com/LucidOcean/multichain/issues/1

I fixed it by these 2 modifications:
1.
You are correct, my ip address was wrong, it should be the physical ip, something like 192.168.*.*

2.
Then I noticed that I used the wrong .conf file to save my password/username. It should be the one together with .param, in my case it is /MultiChain/chain1/multichain.conf
I used /MultiChain/multichain.conf at the beginning, that's why it didn't work.
...