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.

Occasional 401 error when getting contact lists

Highlighted
Occasional Participant

Occasional 401 error when getting contact lists

I have an (Ruby) app that's been in production for a few months without any real problems.  However, for a few of our customers, when we go to fetch their list of contact lists in the app, we get a 401 Unauthorized error.   (We use OAuth2.)  We are unable to reproduce it with our own Constant Contact accounts.  One possible correlation is that these customers all report having a large number of email lists.

 

Any suggestions on how I can chase this down?

 

thanks,

Charles.

Tags (1)
4 REPLIES 4
Highlighted
Employee

Re: Occasional 401 error when getting contact lists

Hi Charles,

 

What you may be running into is an encoding issue.  Some of your user credentials may contain special characters, like an @ symbol if they are using their email address as username, for instance. When you fetch the lists in the account, you get them 50 at a time, then have to make a second request for the next 50 lists.

 

During the first list get request, the user credentials would go through properly, but on the second and subsequent gets, any @ or other special characters may not be encoded properly.  Can you verify that the accounts getting the 401 error have special characters?  If not, there may just be a problem with getting the second page of lists.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: Occasional 401 error when getting contact lists

Hi Sannon,

 

I do not currently have OAuth tokens for the users who were having problems with our app fetching the contact lists.  (Our work-around for them was to remove their tokens and use another feature of our app.)  So, I can't tell for them what the problem was.  However, I did find two other users in our DB who did have an @ symbol in their username.  I was able to fetch the contact lists for them,  One of them contained 3 entries and the other contained 37.  I have asked our customer support to work with some of the customers who were having problems to find out what their username is to see if it fits in this pattern.  I'm also hoping to be able to use the credentials to reproduce the problem in a simple case outside of our larger application.

 

With regards to fetching lists 50 at a time, I understand the general concept of paging through results from a query.  However, I don't see how paging is done when getting contact lists, which probably means it's not implemented in the library I'm using.  When I look at http://community.constantcontact.com/t5/Documentation/Retrieving-a-Contact-List-Collection/ba-p/2506... I don't explicitly see how to pass paging parameters.  I do notice in the result that there is a link that says "next" and with an href to "lists?next=6".  From that I might guess that paging is done with that "next" query parameter.  Is that doumented somewhere that I failed to find?

 

thanks,

Charles.

Highlighted
Occasional Participant

Re: Occasional 401 error when getting contact lists

Following up on my previous post, I can see where the Ruby gem I'm using is handling pagination of results.  I suspect that you're right, Shannon, that there's something going wrong when it goes to fetch the next page.  It could easily be related to the OAuth2 support that I hacked in.

 

I'll report back here with my findings for other people to benefit (hopefully) from my trials and tribulations.

 

thanks,

Charles.

Highlighted
Employee

Re: Occasional 401 error when getting contact lists

Hi Charles,

 

Thank you for keeping us updated.  To answer your question about list next links, it's not explained in detail anywhere (my apologies), but you use the next link by making a get request to the URI as below for your example:

 

https://api.constantcontact.com/ws/customers/username/lists?next=6

 

Best Regards,

Shannon W.

API Support Specialist

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