JKorf / Bittrex.Net

A C# .Net wrapper for the Bittrex web API including all features easily accessible and usable
MIT License
141 stars 62 forks source link

Private Requests results in Unknown Error #58

Closed kyi87 closed 6 years ago

kyi87 commented 6 years ago

I get the following ErrorMessage, when i'm trying to access privat methods, like GetOrderHistory or GetBalances:

ErrorCode 8000: "An unknown error happened Message: Auf das verworfene Objekt kann nicht zugegriffen werden."

I'm assuming my Api-key is not properly working, altough im using the information from the bittrex Settings/Api Keys - Site.. This is how i instantiate the client:

            using (this.m_Client = new BittrexClient(this.ApiKey, this.ApiSecret))
            {
                this.m_Client.MaxRetries = 3;
            }

What could be the reason? Thanks in advance.

UPDATE My API-Key is definitely working,I did a test-request on my own and it was successfull:

            var baseUrl = "https://bittrex.com/api/v1.1/account/getbalances";

            long nonce = DateTime.UtcNow.Ticks;
            var apiKey = "MY_KEY";
            var secret = "MY_SECRET";

            var url = baseUrl + @"?apikey=" + apiKey + @"&nonce=" + nonce.ToString();

            var encryptor = new HMACSHA512(Encoding.UTF8.GetBytes(secret));
            var hash = encryptor.ComputeHash(Encoding.UTF8.GetBytes(url));
            var hashString = ByteToString(hash);

            WebRequest request = WebRequest.Create(url);
            request.Headers.Add("apisign", hashString);

            var response = request.GetResponse();
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var returnedData = reader.ReadToEnd();
                Console.Write(returnedData);
            }

            Console.ReadLine();
kyi87 commented 6 years ago

Okay, i found the problem. My client got disposed after the using-block. So it called disposed and disposed the encryptor, which results in the exception.