The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

403 Forbidden API on creating contact

Highlighted
Member

403 Forbidden API on creating contact

Hello Support Team,

 

We are receiving a 403 Forbidden status when creating contact through APIs. We are using Ruby on Rails Framework and uses "constantcontact" gem.

 

Here is the sample code we used to store bulk contacts.

 

@cc = ConstantContact::Api.new(application_key, user_account_token)

@list_id = @cc.get_lists[0].id

users_info.each do |user|

     response = @cc.get_contact_by_email(user.email)

     next if response && response.respond_to?(:results) && !response.results.empty? 
     
     contact = {'first_name'=> "#{user.first_name}", 'last_name' => "#{user.last_name}" }

     email = { 'email_address' => "#{user.email}"}

     contact['email_addresses'] = []

     contact['email_addresses'] << email contact['lists'] = []

     contact['lists'] << { :id => @list_id }

     new_contact = ConstantContact::Components::Contact.create(contact)

     @cc.add_contact(new_contact) # We are getting 403 forbidden for this line

end

 

It's observed that sometimes APIs workes correctly and save the record in the user's constant contact account but most of the time it returns 403 Forbidden.

1 REPLY 1
Highlighted
Moderator

Re: 403 Forbidden API on creating contact

Hello,

 

Thank you for reaching out to Constant Contact API Developer Support.

 

Would you be willing to email some details to us at webservices(at)constantcontact.com? There are a few reasons this can happen, such as if you are trying to add a previously unsubscribed contact to a list. We'd like to have the following:

- Constant Contact username

- Email address that you are trying to add

 

Please let me know if you have any other questions!

 

Regards,

David B.
Tier II API Support Engineer

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured