We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Good Interactive Logins fail with (500) with the api / Good login intermittently fails with the api (401)

cbaugh
Regular Participant

Good Interactive Logins fail with (500) with the api / Good login intermittently fails with the api (401)

I have two serious issues that I need help with. And these are two issues that I can recreate without problem. The first is that I have logins that I can login with interactively that will fail with the api.  These logins fail with a 500. I also have logins that work flawlessly with the same code with the api. So why do some logins work and some don't? (I'm doing a post to start the process to pull down custom fields when this happens.) The second issue is that I'm doing a get to check the status of the prior post request (when it goes through) and it will often fail with a 401 even though I've just succeeded with the exact same credentials six seconds earlier. And then in six seconds it will then login without an error. So why the intermittent login failures?


These are really big issues for us.


Thanks for any help,


Craig Baugh

6 REPLIES 6
DaveBerard
Moderator

Hi Craig,


 


What language and platform are you programming on?  Also, can you post your code?  Does this also happen on other testing platforms such as the REST Client?  If you can replicate this in the REST Client, please let us know the Username you can replicate this on (you can send this in to our webservices support team). 

Dave Berard
Senior Product Manager, Constant Contact
cbaugh
Regular Participant

Code is c#. I have a web service that takes a request to "update a clients custom fields" From there the request is sent to a windows service that kicks off a thread that makes several calls. The first call is a post of the following:


StringBuilder data = new StringBuilder(); (passedinusername is the username, apikey & unifyer are added in below)

data.Append("activityType=EXPORT_CONTACTS&fileType=CSV&sortBy=DATE_DESC&columns=CUSTOM+FIELD+1&columns=CUSTOM+FIELD+2&columns=CUSTOM+FIELD+3&columns=CUSTOM+FIELD+4&columns=CUSTOM+FIELD+5&columns=CUSTOM+FIELD+6&columns=CUSTOM+FIELD+7&columns=CUSTOM+FIELD+8&columns=CUSTOM+FIELD+9&columns=CUSTOM+FIELD+10&columns=CUSTOM+FIELD+11&columns=CUSTOM+FIELD+12&columns=CUSTOM+FIELD+13&columns=CUSTOM+FIELD+14&columns=CUSTOM+FIELD+15&listId=http%3a%2f%2fapi.constantcontact.com%2fws%2fcustomers%2fa..apikey..f9%");

data.Append(passedinusername);

data.Append("%2Flists%2F1");


 


From this I get the url to check to see if the status is pending or complete. I check this status via a get every six seconds. If it's complete I then use a get to pull it down and parse it, etc.


 


There are two problems. The first is that I have logins that work fine as far as logging into the CC web site. However, when I try to use them this way I get an immediate 500 on the post. (Since these are all "test accounts" is there some type of check? I have new test accounts and old test accounts, some of which are past the "test period". Would this matter?) But I also have several accounts that work perfect. So I don't believe it's a code issue but rather how the backend is responding to the different logins.


 


The second problem is that in my service that checks every six seconds, I often get a "good response", "good response", "401", "good response", 401, etc. Since I trap the 401 I eventually get a status of Complete even if I've gotten several 401's along the way. The problem though is why am I getting 401's at all? It concerns met GREATLY that I am getting these intermittent failures.


 


As far as using a rest client, I usually have better luck. (btw, I don't use the one you recomend because I don't want the Java overhead. Using either Fiddler or the FF addon called RESTCLIENT are MUCH better tools for testing this stuff.)  I don't normally get 401's when I use a rest client, however if I hit it several times in a row I can generate a 401 and sometimes a 500 as well.


 


As far as using a rest client and the post from above, I have certain logins that immediately return a 500 even though I can login interactively.


 


I do wonder if the post from above is the best way to pull these fields. ie, pulling from list 1 vs pulling from do not mail, etc.


 


On a side note if you just gave me a function getCustomFields(string userName, user, credentials.....) if it would make my life MUCH simpler.


 


Thanks,


Craig Baugh

 


 

DaveBerard
Moderator

Hi Craig,


 


That's some great information.  Is it possible for you to send some of the usernames that cause intermitent failures and some that succeed all the time to me?  I'd like to run some tests on our side via C# as well and see if I can replicate.  If it's occuring using the same code, that does indicate some sort of an issue on our end.  


 


Couple more clarification questions, are you using Digest or Basic authentication?   Does the 401/500 issue also occur on other collections than the Bulk Activities?  If so, what other Collections? 


 


Regarding the getCustomFields question, the easiest way I can think of to do this is currently a two step process:


 



  1. Query the email address as a GET to the Contacts Collection: https://api.constantcontact.com/ws/customers/{username}/contacts?email={email address here}

  2. Using the returned XML from the query, run a GET on the Contact Details: https://api.constantcontact.com/ws/customer/{username}/contacts/{userID}


 


 


This will return to you a full XML doc on the contact you searched for which will include the Custom Fields.  You can then update this information (XMLDocument and XMLNode classes can be used to make this very easy) and PUT back the information to the same URL.  This is instant as well so you will get a 201 Success or 409 Conflict immediately.  There will be no need to check periodically to see if is successful as you do with the Bulk Activities collection.  This should cut down alot of your processing time and alot of your API call overhead.


 


If you have any questions on how to parse the XML Document in C#, here is a great post on how to set up the Schema in C# so that the language does all the work for you.

Dave Berard
Senior Product Manager, Constant Contact
DaveBerard
Moderator

Hi Craig,


 


I was just talking to one of our engineers regarding what you are looking to actually do with the Custom Fields.  I apologize for the confusion, the method you're using is actually the only way to currently get the information you are looking for (being the modified names for Custom Fields 1-15).  This is being looked at by our developers, though I can't give any ETAs on when they will look into this feature request.

Dave Berard
Senior Product Manager, Constant Contact
cbaugh
Regular Participant

Dave, Unfortunately I was already aware that the methods you outlined in your earlier post about the custom field names wasn't going to work. I REALLY, REALLY, REALLY would love a way to pull down the renamed custom field names without having to do it the way I'm doing it. (It's a LOT of work on my end for something incredibly simple. But it's a BIG issue for us...)


 


I'll send to the webservices email account some username / passwords for you guys to try.


 


Thanks,


Craig

DaveBerard
Moderator

Thanks Craig,


 


I got your email and I responded with some follow up.  I do want to let you know we have a feature request in regarding the Custom Fields.  We are looking into this going forward, though I can't provide an exact time frame.  Once we do release an easier way to accomplish what you are looking for, we will post this in the forums and you should also receive an email regarding the changes.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page