0
string url = @"https://api.bitfinex.com/v1/balances";
string paramDict = "{\"request\": \"/v1/balances\",\"nonce\": \"" + GetNonce() * 10000 + "\"}";
string payload = Convert.ToBase64String(Encoding.ASCII.GetBytes(paramDict));
string signature = BitConverter.ToString(hmac.ComputeHash(Encoding.ASCII.GetBytes(payload))).Replace("-","").ToLower();
var headers = new Dictionary<string, string>
{
{"X-BFX-APIKEY",key},
{"X-BFX-PAYLOAD",payload},
{"X-BFX-SIGNATURE",signature}
};
var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
if (request == null)
throw new Exception("Non HTTP WebRequest");
var data = System.Text.Encoding.ASCII.GetBytes(paramDict);
request.Method = "POST";
request.Timeout = 30000;
request.ContentLength = data.Length;
foreach (var a in headers)
{
request.Headers.Add(a.Key, a.Value);
}
var write = request.GetRequestStream();
write.Write(data, 0, data.Length);
var respone = request.GetResponse() as HttpWebResponse;
This is my code. Maybe you can see where I made an error. As for me, API is normal made.
When I run this code it returns an HTTP 400 error code.
1I Use c#, i try many type of headers, 1-st error was with forming hmac string payload = EncodeTo64(paramDict); string message = payload; string skey = secret; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] keyByte = encoding.GetBytes(skey); HMACSHA384 hmacsha384 = new HMACSHA384(keyByte); byte[] messageBytes = encoding.GetBytes(message); byte[] hashmessage = hmacsha384.ComputeHash(messageBytes); string signature = this.ByteToString(hashmessage); – Yura Sultanov – 2015-01-28T23:44:03.960
I see you posted a self-answer, did you happen to fix the whole issue and tackle other bugs? Are you getting a 200 OK now? Can't help much with C#, thought I'd throw some pointers at the least though. – Dhuum – 2015-01-28T23:57:30.617