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.

HTTP 406 error on event list API call

PhilA
Member

HTTP 406 error on event list API call

Hi,

 

I have just checked in on an automated process that gets event lists and event details for my client (username 0017score) and I'm getting an HTTP error as the event list response: 406 Not Acceptable 

 

-- EDIT --

I'm getting this back in the body of the response: Error 406: '*/*' is not supported

 

Could somebody elaborate on what is going on here. Nothing has changed in the client code in over a week and it was last working fine yesterday.

 

Thanks,

Phil

Phil Ayres

Principle - Consected
14 REPLIES 14
Ryan_D
Employee

Hi Phil,


I am currently looking into this for you.  As soon as I can get it to replicate I will post back here.  Please keep me posted if anything changes.

Ryan Davis
Quality Engineer

Hey Phil,


Can you please provide me with the specific URI that you are requesting the GET from?

Ryan Davis
Quality Engineer

Hey Phil,

 

We have done some testing and we found that the issue is coming from where the headers are being declared.  When you set your headers it needs to be in all lowercase.

 

content-type: application/atom+xml
accept: application/atom+xml

For some reason when I used any assortment of capital letters I received a 406 error.  If you can try to update the code accordingly and let me know if this fixes your issue.

Ryan Davis
Quality Engineer

Sorry, that doesn't fix it

Phil Ayres

Principle - Consected

Hey,

 

Can you give the snippet of code where you do your request with your headers included?

 

 

Ryan Davis
Quality Engineer

Actually, I lied. I didn't change the headers in the right piece of code. But, until I can get some more information about what is being passed, I think it is worth noting the following.

 

If I go to a new browser and enter the URL:

https://api.constantcontact.com/ws/customers/0017score/lists

 

It gives me a basic authentication prompt. I can login with the APIKEY%username and password format fine.

 

If I go to:

https://api.constantcontact.com/ws/customers/0017score/events 

in a fresh browser, I just get this response:

Error 406: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' is not supported

 

Based on the fact that the events API appears to be broken, I'm not going to make changes in my code. Once we have the ability to get the events list using basic authentication I'll try again.

 

Phil

Phil Ayres

Principle - Consected

The code I'm using is Ruby, using the oauth gem, which has been working fine for weeks. There is not very much to see, as it is a simple get request against an access token that was working successfully up until 2 days ago.

 

username = '0017score'
url = "https://api.constantcontact.com/ws/customers/#{username}/events"
res = @access_token.get(url)

 Phil

Phil Ayres

Principle - Consected

Hey Phil,

 

The reasoning for that error is because /lists does not require the accept: application/atom+xml passed through the header but /events does require it.  Since your going through the prowser and the headers are looking for xhtml its getting that error.  You can read some of the documentation about the events area here.  

 

Our engineers are investing the issue and they are working diligently to a more permanent solution.  

 

Ryan Davis
Quality Engineer
CharlesL9
Occasional Participant

We also started getting this error yesterday.

 

Since most of us use 3rd party oAuth libraries, customizing the capitalization of the headers isn't something we often can easily change. Why is this something that was changed? The capitalization of header text isn't something that should break a previously working API request.

Ryan,

 

I see for the first time in the API docs the requirement for   accept: application/atom+xml

 

I've been happily ignoring this requirement for months, so whatever is being passed in is the default OAuth headers from my Ruby gem (probably Accept: */*, which could be considered to be valid presumably).

 

For a simple Get request, adding headers seems unnecessary. And since it wasn't enforced previously by the API, and other Constant Contact APIs don't request it, suddenly requiring it makes little sense, and seems inconsistent. I don't see the value, unless the developers are going to quietly sneak in other response formats in the near future (in which case a URI parameter requesting the required format would be way easier to handle, and would be inline with Google, Salesforce, Twitter and everybody else I've integrated with).

 

So, my preferred solution to this is to remove the required headers, to take us back to where we were previously, and not try and match the documentation.

 

My SCORE client is waiting on a solution, since they are not getting new workshops published on their new mobile websites, and are not getting reports of attendance, essential for their reporting to the SBA. Just so you understand why this is important to prioritize.

 

Thanks,

Phil

Phil Ayres

Principle - Consected

Hey Guys,

 

Our engineers are working on this issue and I will have more information tomorrow.  I understand this is frustrating for everyone and we are working on more permanent fix. 

 

Ryan Davis
Quality Engineer

I have just tested the solution Ryan suggested, using headers. After some trial and error I got it to work.

 

Bear in mind, event APIs (both list and event details)  require lowercase content-type and accept headers. Registrant APIs have also been broken / enforced, but these for some reason only require the accept header. Since I'm not submitting any content in the event API, I don't really like the idea of adding a header indicating a content-type, and I don't like it breaking the HTTP RFC for being case insensitive. But it works for now.

 

For anybody using the Ruby OAuth gem, here is an example of how to add lowercase headers to the Get request submitted against an access token:

 

url = "https://api.constantcontact.com/ws/customers/#{username}/events"
headers = {'accept'=>'application/atom+xml', 'content-type'=>'application/atom+xml'}
res = @access_token.get(url, headers)

 

Phil

Phil Ayres

Principle - Consected

Hey Phil,

 

Thank you for letting me know this worked and providing an example. 

Ryan Davis
Quality Engineer
Developer Portal

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

Visit Page