Enter the Share Your Success Sweepstakes 2024 For the Chance to Win Great Prizes!

403 Forbidden API on creating contact

user137474
Rookie
0 Votes

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.

2 REPLIES 2
David_B.
Employee
0 Votes

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

user325362
Rookie
0 Votes

This error indicates that the server has determined that you are not allowed access to the thing you've requested, either on purpose or due to a misconfiguration . It's probably because the site owner has limited access to it and you don't have permission to view it. The vast majority of the time, there's not much you can do to fix things on your (*client) end. There are four common causes for 403 Forbidden error (server side) . Here they are listed from most likely to least likely:

 

  • An empty website directory
  • No index page
  • Incorrect settings in the .htaccess file
  • Permission / Ownership error

 

If authentication credentials were provided in the request, the server considers them insufficient to grant access. The client SHOULD NOT automatically repeat the request with the same credentials. The client MAY repeat the request with new or different credentials. However, a request might be forbidden for reasons unrelated to the credentials.

 

Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up