50: Must supply a valid HTTP Basic Authorization header

Using createsend ruby gem (3.1.1):

auth = {:api_key => "foo"}
list_id = "bar"
email = "johndoe@example.com
CreateSend::Subscriber.add auth, list_id, email, "Subscriber", [], true

I receive following error:

CreateSend::Unauthorized in Users::AccountsController#create

The CreateSend API responded with the following error - 50: Must supply a valid HTTP Basic Authorization header

I tested credentials via plain HTTP, tried two list IDs - same thing. Any tips?

jamesd jamesd, 4 years ago

Hey there,

This doesn't seem to be an issue specific to the createsend gem. It appears to be an issue with the API key you are using.

You'll need to make sure you're getting your API key from within your account, as described here.

And you'll need to get your list ID as described here.

If you're using the correct values, you shouldn't have a problem calling CreateSend::Subscriber.add.

The equivalent curl call to test this would be:

curl -u "{apikey}:x" https://api.createsend.com/api/v3/subscribers/{listid}.json -X POST -d \
    "EmailAddress": "subscriber@example.com",
    "Name": "Subscriber",
    "CustomFields": [],
    "Resubscribe": true,
    "RestartSubscriptionBasedAutoresponders": true

If you're sure you're using the correct API key and list ID and you still can't add a subscriber using either the createsend gem or the curl call above, I'd suggest you contact support including your Campaign Monitor account URL so that they can look up the logs of the API calls made for your account.

Hope that helps.

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