I am trying to use this API
bitmarket
First I would like to call basic method info
that's why in postman
I added to headers to fields:
API-Key
-> my api keyAPI-Hash
-> my hash which is generated below) viaHMAC SHA512
signature.
How I generate API-Hash
?
I have written in Java
simple method which looks like:
public String encodeDataViaHMAC(String msg, String keyString, String algo) {
String digest = null;
try {
SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
Mac mac = Mac.getInstance(algo);
mac.init(key);
byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
StringBuffer hash = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(0xFF & bytes[i]);
if (hex.length() == 1) {
hash.append('0');
}
hash.append(hex);
}
digest = hash.toString();
} catch (UnsupportedEncodingException e) {
} catch (InvalidKeyException e) {
} catch (NoSuchAlgorithmException e) {
}
return digest;
}
and then I pass to it parameters:
- map of request parameters:
Map<String, Object> m = new LinkedHashMap<>();
m.put("method", "info");
m.put("tonce", System.currentTimeMillis());
- private key
- method name which is
HmacSHA512
and after that I still get it postman
error:
{"error":502,"errorMsg":"Invalid message hash","time":1514023708}
Does anyone can help what am I doing wrong and can help me to fix it?