"Ошибка проверки подписи".< /p>
Я следую документации и правилам формирования запроса и расчета подписи.
Ниже приведен полный код :
Код: Выделить всё
HttpClient client = new HttpClient();
string key = "";
string secretKey = "";
// parameters of request
string parameter = "leverage=3&openType=1&price=24500&side=1&symbol=BTC_USDT&type=1&vol=0.001";
// current time (Unix)
long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
// concatenate params
string param = key + time + parameter;
// calc signature
using var encryptor = new HMACSHA256(Encoding.UTF8.GetBytes(secretKey));
var resultBytes = encryptor.ComputeHash(Encoding.UTF8.GetBytes(param));
var signature = string.Empty;
foreach (var t in resultBytes)
signature += t.ToString("X2");
signature = JsonConvert.SerializeObject(signature);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"https://contract.mexc.com/api/v1/private/order/submit?{parameter}");
request.Content = new StringContent("application/json", Encoding.UTF8);
// add headers
request.Headers.Add("ApiKey", key);
request.Headers.Add("Request-Time", time.ToString());
request.Headers.Add("Signature", signature);
HttpResponseMessage response = await client.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
// {\"success\":false,\"code\":602,\"message\":\"Signature verification failed!\"}
Console.WriteLine(responseBody);
https://mxcdevelop.github.io/apidocs/co ... ion-method
Ссылка из документации на способ отправки заказа
https://mxcdevelop.github.io/apidocs/co ... aintenance
Пожалуйста, помогите решить эту проблему.
Подробнее здесь: https://stackoverflow.com/questions/770 ... ify-failed