title: Kraken private API with F# returns EGeneral: invalid arguments
body: <p>I am trying to access the Kraken private API using F#. The code to access the public API runs perfectly fine, but when i try to access the private API i am always getting the error "EGeneral:Invalid arguments".</p>
  
  <pre><code>#r "FSharp.Data.dll"
  
  open FSharp.Data
  open System
  open System.Text
  open System.Security.Cryptography
  
  let baseUri = "https://api.kraken.com"
  let key = MY_KRAKEN_API_KEY
  let secret = MY_KRAKEN_API_SECRET
  let path = "/0/private/Balance"
  let nonce = DateTime.UtcNow.Ticks
  let bodyText = "nonce=" + nonce.ToString()
  
  let hmac (key : byte []) (data : byte[]) =
      use hmac = new HMACSHA512(key)
      hmac.ComputeHash(data)
  
  let sha256 (data : string) =
      use sha = SHA256Managed.Create()
      sha.ComputeHash(Encoding.UTF8.GetBytes(data))
  
  let createSignature (nonce : int64) body (path : string) secret =
      let shaSum = nonce.ToString() + body |&gt; sha256
      let data = Array.append (Encoding.UTF8.GetBytes path) shaSum
      let key = Convert.FromBase64String secret
      hmac key data |&gt; Convert.ToBase64String
  
  let signature = createSignature nonce bodyText path secret
  
  let response = Http.RequestString (
      url = baseUri + path,
      httpMethod = "POST",
      headers = ([("API-Key", key); ("API-Sign", signature)] |&gt; Seq.ofList),
      body = TextRequest bodyText
  )
  </code></pre>
  
  <p>Does anybody see what i am doing wrong?</p>
  
  <p>EDIT:
  The Kraken.com API documentation is awailable here: <a href="https://www.kraken.com/help/api" rel="nofollow">https://www.kraken.com/help/api</a></p>
  
  <p>I suppose the header signature is incorrect. The docu requires the following two values to be submitted in the header:</p>
  
  <blockquote>
    <p>API-Key = API key API-Sign = Message signature using HMAC-SHA512 of
    (URI path + SHA256(nonce + POST data)) and base64 decoded secret API
    key</p>
  </blockquote>
  
  <p>EDIT 2:
  The remaining parameters need to be transmitted with a POST method. In my case this is only the "nonce" value in the body part of the HTTP request.</p>