HMAC payload in Ruby from Java HMAC example

One of the part of API auth is to create bodyHash as a part of headers. The documentation is laconic:

Hash of the message body using the HMAC Sha256 algorithm. Your secret key is used to generate the hash.

And they provided an example in Java:

import java.util.UUID;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;

public class AuthorizationMacHeader {
    private static final String HMAC_SHA256_ALGORITHM = "HmacSHA256";
    private static final String UTF8_ENCODING = "UTF-8";
/**
 * @param key_id
 *            : Your key id
 * @param secret_key
 *            : Your secret key
 * @param payload
 *            : payload
 * @return
 * @throws Exception
 */

 // create the bodyHash value by hashing the payload and encoding it
 SecretKeySpec signingKey = new SecretKeySpec(secret_key.getBytes(UTF8_ENCODING), 
 HMAC_SHA256_ALGORITHM);
 Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM);
 mac.init(signingKey);
 byte[] rawBodyHash = mac.doFinal(payload.getBytes(UTF8_ENCODING));
 String bodyHash = Base64.encodeBase64String(rawBodyHash);

So what I did in Ruby was:

require 'json'
require 'base64'
require 'openssl'

KEY_ID = 'Syb6i+sRygAGCgxLQJ4NwwKcT5'
SECRET_KEY = 'Mnkh4r3QXgwZ3vmcE='

payload = { some: 'hash' }.to_json

mac = Base64.strict_encode64(OpenSSL::HMAC.digest('SHA256', SECRET_KEY, payload))

puts mac
 => "DzWVea1hH+F3S2SuYWfyBjGCJI0bJ4393+kH1dU6LFc="

But I'm not sure if this is correct because the Java class has UTF8_ENCODING part. I don't understand what this is all about?

If something will be unclear, full example of java class below: https://gist.github.com/mrmuscle1234/881144360e13ac1ac1794610c456d035

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum