I answered your question more completely here, in the context of the Poloniex exchange:
Ruby Http Post Parameters
To answer your specific questions from this post:
- How do I find my post request data?
POST data simply means the body of your request. This could be JSON, plain text, form data, etc. In cases where a specific format (i.e. JSON) isn't mentioned, POST data probably refers to POST form data (Content-Type: application/x-www-form-urlencoded
). This is how data submitted from a web form is formatted and indeed that appears to be what Poloniex is looking for.
x-www-form-urlencoded
data can be produced like this in Ruby:
form_data = URI.encode_www_form({:command => 'returnBalances', :nonce => Time.now.to_i * 1000 })
puts form_data
command=returnBalances&nonce=1447537613000
Mozilla Developer's Network link on POST form data.
- How do I use the HMAC-SHA512 method to encrypt this data so that I can send it in a header? (using Ruby)
HMAC digest produces a unique string based on a secret key and the data provided. In Ruby, you can produce an HMAC digest like so:
OpenSSL::HMAC.hexdigest( 'sha512', secret, form_data)