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, 3 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.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098