【问题标题】:I can not authorize to hitbtc api from c#我无法从 c# 授权 hitbtc api
【发布时间】:2018-08-15 00:59:44
【问题描述】:

我的代码是:

HitBtcApi.HitBtcApi hitbtc = new HitBtcApi.HitBtcApi();
hitbtc.Authorize("xxx", "xxx");            
RestRequest request2 = new RestRequest("/api/2/account/balance", method.GET);
var x= await hitbtc.Execute(request2, true);    
MessageBox.Show(x.content.ToString());

运行时出现此错误: {"error":{"code":1001,"message":"Authorization required","description":""}} 但是当我使用 "/api/2/public/symbol" 而不是 "/api/2 /account/balance”它工作。请帮我。谢谢。

【问题讨论】:

    标签: c# authorization exchange-server trading


    【解决方案1】:

    您是否为您的 API 密钥激活了对特定 API 的访问权限?

    https://hitbtc.com/settings/api-keys

    using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Authorization = new
                        System.Net.Http.Headers.AuthenticationHeaderValue("Basic",
                            Convert.ToBase64String(
                                Encoding.ASCII.GetBytes(
                                    "user:pass")));
    
                    var result = await (await client.GetAsync("https://api.hitbtc.com/api/2/trading/balance")).Content
                        .ReadAsStringAsync();
                }
    

    【讨论】:

    • 感谢您的帮助。我的访问没有问题。当我尝试你的代码时,它就像一个魅力。
    • 没问题,如果是则标记为答案!
    • 嗨,亲爱的 Khatibzadeh,您能告诉我如何进行买卖订单以及如何取消订单。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    • 2019-02-10
    • 1970-01-01
    • 2014-08-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多