我正在尝试向Livecoin API发送POST请求。我确保每个参数和编码都是正确的,但我一直得到一个奇怪的回应:
{"success":false,"exception": "Unknown currency pair [currencyPair={1}]|null"}
这就是我要发布的内容:
string response = PrivatePostQuery("exchange/buymarket", "currencyPair=BTC/USD&price=12&amount=12");
这是方法:
public string PrivatePostQuery(string requestUrl, string parameters = "")
{
parameters = http_build_query(parameters);
string Sign = HashHMAC(this.Exchange.ExchangeConnection.ApiSecretKey, parameters).ToUpper();
string uri = this.Exchange.ExchangeConnection.ApiUrl + requestUrl + "?" + parameters;
byte[] bytes = Encoding.UTF8.GetBytes(parameters);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;
request.Headers["Api-Key"] = this.Exchange.ExchangeConnection.ApiKey;
request.Headers["Sign"] = Sign;
Stream dataStream = request.GetRequestStream();
dataStream.Write(bytes, 0, bytes.Length);
try
{
WebResponse WebResponse = request.GetResponse();
dataStream = WebResponse.GetResponseStream();
StreamReader StreamReader = new StreamReader(dataStream);
return StreamReader.ReadToEnd();
}
catch (WebException ex)
{
return new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}
}
我已成功从API获取代码和余额,因此问题不在于签名或标题。
我尝试将请求更改为大写/小写,并将参数添加为请求标头,在URL中包含和不包含它们。
感谢您的帮助!
答案 0 :(得分:0)
好的,所以没有任何问题,LiveCoin兑换不适用于BTC-USDT对,只有BTC-USD。所以反应是正确的,甚至是艰难的,它有点乱。