'C-patex api says: Invalid signature
I am trying to create a crypto bot for the c-patex exchange on Pascalabc. I'm stuck on private requests using a key and a secret key. I get an error - {"error":{"code":2005,"message":"Signature is incorrect."}}
This is my code:
function GetOrders.TGetOrders.GetOrders: string;
begin
var hmac := new HMACSHA256(Encoding.UTF8.GetBytes('xxx'));
var timestapm := (System.IO.StreamReader.Create(System.Net.WebRequest.CreateHttp('https://c-patex.com//api/v2/timestamp.json').GetResponse.GetResponseStream).ReadToEnd.ToBigInteger * 1000).ToString;
var sigstring := 'GET|/api/v2/orders|access_key=yyy&tonce=' + timestapm.ToBigInteger / 100 + '&market=compdoge';
var compute := hmac.ComputeHash(Encoding.UTF8.GetBytes(sigstring), 0, Encoding.UTF8.GetBytes(sigstring).Length);
var signature := System.BitConverter.ToString(compute).Replace('-', string.Empty).ToLower();
var reqstring := 'https://c-patex.com//api/v2/orders?access_key=6BckEAz52cOwpx1gfT0nByhLxkNF8uzzTFdzT8Oa' +
'&market=compdoge' +
'&signature=' + signature +
'&tonce=' + timestapm;
Writeln(reqstring);
try
var request := System.Net.WebClient.Create;
var data := request.DownloadData(reqstring);
except
on ex: System.Net.WebException do
begin
var Response := ex.Response;
var stream := Response.GetResponseStream;
var Reader := new System.IO.BinaryReader(Stream);
var res := Reader.ReadBytes(stream.Length);
var chararr := Encoding.UTF8.GetChars(res);
var output := System.string.Create(chararr);
Writeln(output);
end;
end;
end;
end.
Has anyone worked with the api of this exchange? Have you had a similar problem? Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
