Example #1
0
        private static async Task <RpcResponse> MakeRequestAsync(string methodName, params object[] args)
        {
            var response = await client.PostAsync("", new StringContent(MethodCallContext.ToJson(MyVersion, methodName, args)));

            var result = RpcResponse.FromJson(await ReadContent(response));

            if (result.JsonRpcVersion != MyVersion)
            {
                throw new Exception($"Incompatible RPC versions result {result.JsonRpcVersion} vs current {MyVersion}");
            }
            if (result.Error != null)
            {
                throw new Exception(result.Error?.Message);
            }
            return(result);
        }