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.

Occasional 400 errors

Occasional 400 errors

In general the API works well, but recently we have noticed intermittent 400 errors.  Generally a transaction goes through fine; sometimes we get a 400 error.  Resend - sometimes goes through second time, sometimes third time.  Always works eventually.  I guess I can write some code to automatically resend (say) 5 times if I get a 400 error, but that seems like a kluge...any suggestions?

 

It is difficult to post sample code as it is all dynamically generated..so would welcome suggestions.  Do your servers send a 400 error if they are receiving too many requests?  (BTW, we average perhaps 4 a day......so not too many!)

6 REPLIES 6
Richard_M
Member

Hi,

 

What are you using the API for (for example, adding contacts)? Could you post the code you are using for us to look at (with any passwords and API keys removed, of course). Does the issue happen at certain times of the day or certain days?

 

Thanks,

Richard Maxwell
Support Engineer, Constant Contact

The error we see is when a subscriber is resubscribing (status="Do Not Mail" to status="Active"). I have not identified a time pattern.

I tested the API manually at around 12.00PST today. Using identical code, 4 subscribers who had previously tried to resubscribe went through fine, one required two tries, one required 3 tries.

I have also spent a few hours this afternoon (aftyer your reply) working on it, and can find no consistent pattern.  Below are example XML dumps.  To enable me to better see what is going on, I added the API response into custom field 1 for the dump, not sent to the API!.  As you will see, this time it took 2 tries. When the opt-in works, I get "204 No Content" as a response.  If it does not work, I see "400 bad request"

The testing process I used this afternoon was to manually go onto CC, mark a subscriber as "Do Not Mail", and attempt to resubscribe thoguh the API.  First try required two attempts (screen refreshes). Went back onto CC, marked as "Do Not Mail".  Resubscribed - worked first time.  Repeated.  Worked first time.  Repeated.  Took 3 tries. <sigh>

I also used the "get" command to get the subscriber details before and after the API call to see what was going on.....no smoking bullet!

Interestingly, after I have successfully resubscribed a contact, I generally search for them in Constant Contact to recheck the status (although through the "get" indicates they are Active).  Sometimes they come up in CC as "Active"; sometimes as "Do Not Mail".  I just searched for a contact who was noted in the search screen as "Do Not Mail", clicked on the name for more information, where the contact was marked as "Active". Searched again: "Do Not Mail". Generally logging out and logging back in helps....wild thought, I assume your servers are in a cluster, could one node be out of synch somehow? Could this have something to do with the intermittent problem we are seeing?

Below is a recent dump of the XML file.  To better problemsolve, in the custom field 1 (in the dump not sent to the API) I included the response.



id           http://api.constantcontact.com/ws/customers/xxxx/contacts/xxxx
xmlns        http://ws.constantcontact.com/ns/1.0/
Status       Do Not Mail
EmailAddress xxxx@xxxx.com
EmailType    HTML
Name         xxxx
FirstName    Paul
MiddleName    
LastName     xxxx
JobTitle    
CompanyName    
HomePhone    
WorkPhone    
Addr1    
Addr2    
Addr3    
City    
StateCode    
StateName    
CountryCode    
CountryName    
PostalCode    
SubPostalCode    
Note            Member added from xxxx admin
CustomField1    response: 400 Bad Request
CustomField2    
CustomField3    
CustomField4    
CustomField5    
CustomField6    
CustomField7    
CustomField8    
CustomField9    
CustomField10    
CustomField11    
CustomField12    
CustomField13    
CustomField14    
CustomField15    
Confirmed       true
InsertTime      2011-01-05T21:37:35.648Z
LastUpdateTime  2012-04-28T01:41:05.589Z
OptInSource     ACTION_BY_CONTACT
ContactLists    ContactList    id    https://api.constantcontact.com/ws/customers/xxxx/lists/xxxx
                ContactList    id    https://api.constantcontact.com/ws/customers/xxxx/lists/xxxx


id           http://api.constantcontact.com/ws/customers/xxxx/contacts/xxxx
xmlns        http://ws.constantcontact.com/ns/1.0/
Status       Do Not Mail
EmailAddress xxxx@xxxx.com
EmailType    HTML
Name         xxxx
FirstName    Paul
MiddleName    
LastName     xxxx
JobTitle    
CompanyName    
HomePhone    
WorkPhone    
Addr1    
Addr2    
Addr3    
City    
StateCode    
StateName    
CountryCode    
CountryName    
PostalCode    
SubPostalCode    
Note            Member added from xxxx admin
CustomField1    response: 204 No Content
CustomField2    
CustomField3    
CustomField4    
CustomField5    
CustomField6    
CustomField7    
CustomField8    
CustomField9    
CustomField10    
CustomField11    
CustomField12    
CustomField13    
CustomField14    
CustomField15    
Confirmed         true
InsertTime        2011-01-05T21:37:35.648Z
LastUpdateTime    2012-04-28T01:41:05.589Z
OptInSource       ACTION_BY_CONTACT
ContactLists      ContactList    id    https://api.constantcontact.com/ws/customers/xxxx/lists/xxxx
                  ContactList    id    https://api.constantcontact.com/ws/customers/xxxx/lists/xxxx

As I said, I can code things on my side to capture any 400 errors and simply resubmit the same information mutliple times, but it seems like a bit of a kluge.

I was able to reproduce the behavior you mentioned.  We're going to look into the cause, which is internal service process on our side.  There is nothing you are doing wrong with the request that I can see, will update you once we have more information or if we identify a field that will cause this to no longer occur.

Dave Berard
Senior Product Manager, Constant Contact

Hey Dave,

Any progress on this?  The problems are still (occasionally) occuring.

We have identified the cause of the error messages and are working to resolve them.  Currently, we've only been able to reproduce this behavior when updating a contact on the Do Not Mail list and trying to update their information or opt them back in. 

 

Is this the same behavior you're seeing? 

Dave Berard
Senior Product Manager, Constant Contact

That does indeed seems to be the case.  It is difficult to tell when you allow people to manage their own subscriptions; but we have not come across any problems with people adding new accounts, or with our deactivation/removal of a subscriber.

 

However, we are changing the software this week to record the calls made to your API s we can manually check failed  transactions.

Developer Portal

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

Visit Page