CreateSend Ruby Gem using api_key fails


I'm trying to find subscribers through the api using the ruby CreateSend gem.
I have the client id and the api_key and the inital request works. But when I try to query further into the api It appears to fail trying to access the @auth_details as an hash. That fails because when using the api_key the @auth_details is a string, if I was using OAuth then @auth_details would be a hash.

That is at least what I think is the problem.

>>client = CM_CLIENT_ID, :api_key => CM_API_KEY
>>client.lists //Fails with the error "undefined method `has_key?' for @auth_details"

Maybe I'm doing it wrong.

I have tried sending the api_key with the client.lists function.

I was hoping to do something like this:

>>client = CM_CLIENT_ID, :api_key => CM_API_KEY
>>list = client.lists.first
>>subscriber = CreateSend::Subscriber.get, "", :api_key=>CM_API_KEY

But I need the

Could you tell me if I'm just doing it wrong ?
Kind regards,

Birgir, 3 years ago

I see now in my terminal that I'm definitively doing this wrong. Lack of sleep I guess :)
Could you guys point me in the right direction though ?

Kind and sleepy regards :)

Birgir, 3 years ago


good night :)

Birgir, 3 years ago

Update:: The gem works perfectly. I just didn't realize I had to put curly brackets around `:api_key=>'key'`

It isn't  shown in the example on

Anywho, thanks for the help and here Is my ruby code if anyone want's it.

  def subscribed_to_emails
    cm ={:api_key=>CM_API_KEY},CM_CLIENT_ID)
    active_subscriptions = cm.lists_for_email({|i| i.SubscriberState.downcase=="active"}

  def unsubscribe_from_emails
    cm ={:api_key=>CM_API_KEY},CM_CLIENT_ID)
    lists = cm.lists_for_email(
    lists.each do |list|
      if list.SubscriberState.downcase == "active"
          success = true
          success = false
    return success
roshodgekiss roshodgekiss, 3 years ago

Awesome, glad you got it working, Birgir! Let us know if you have any further questions :D

Get in touch with us on Twitter:
We're also on Facebook:

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free