401 Unauthorized when calling /groups with GET (Ruby on Rails RoR)

From the pre-request script, I convert JS to RoR code:
def generateAuthHeader(dataToSign)

hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), config[:api_secret], dataToSign)

Base64.encode64(hash).strip

end

date = Time.now.httpdate

When I try to replace Authorization & Date generated from Postman example to API calls , it's possible to get 200.
But with the generateAuthHeader method, I can't get 200.

Can anyone give me some advices ?
Thanks so much !

Best Answer

  • thang
    thang Newcomer
    Answer ✓

    Hi everyone,

    Thank you so much for your help.
    The bugs are from the way I use HTTParty to create the header, not from WC1 side.

    Thank you so much !

Answers