• alex chernik
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have an integration (using REST) with externl app and I need to get information from this app each 5 seconds. I have enough API callout numbers on my org.
But it should in the backend. Schedule jond is not enought (100 max)
Can we probably use Heroku or do you know some other approach?
Thank yu
I have an integration (using REST) with externl app and I need to get information from this app each 5 seconds. I have enough API callout numbers on my org.
But it should in the backend. Schedule jond is not enought (100 max)
Can we probably use Heroku or do you know some other approach?
Thank yu

Hi all:

I am trying to consume Kraken API from Apex. Here is the link to their API:

https://www.kraken.com/help/api#general-usage

For the public market data, it works without any problem. However can't get the Private user data API working. For Private calls, we need to provide Signature and Key. 

API-Key = API key
API-Sign = Message signature using HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key

Here is my code:

           request.setHeader('API-KEY', 'XYZ');    //API-Key = API key	        
	       private static String getNonce{
    		 get{
    			return String.valueOf(System.currentTimeMillis());
    			
    		 } 
    		 set;
    	    }            
            String path = '/0/'+endPoint;
            String secret = 'ABC==';
            String payLoad = null //Not passing any data at this stage
            Blob digest = Crypto.generateDigest('SHA-256', blob.valueOf(getNonce+payLoad));
            Blob pathBlob = Blob.valueOf(path);
            
            String combinedDataAsHex = EncodingUtil.convertToHex(pathBlob) + EncodingUtil.convertToHex(digest);
            
	        Blob combinedDataAsBlob = EncodingUtil.convertFromHex(combinedDataAsHex);
            
            Blob apiSignature = Crypto.generateMac('hmacSHA512', combinedDataAsBlob, EncodingUtil.base64Decode(secret)); 
            request.setHeader('API-Sign', EncodingUtil.base64Encode(apiSignature));

I made sure the key and secret are exact. Now when I execute the following line:

HttpResponse response = new Http().send(request);

the reasponse code is always 200 OK. However when I print the response, I see:

15:58:53:953 USER_DEBUG [843]|DEBUG|RESPONSE: {"error":["EGeneral:Internal error"]}

If someone can please help me that would be great. May be I am doing something wrong when generating the combined data as Blob?!

Any help will be much appreciated.

Thanks and regards,
Anindya