cancel
Showing results for 
Search instead for 
Did you mean: 

Error: Invalid content encoding type. API only supports gzip.

SOLVED
Occasional Contributor

Error: Invalid content encoding type. API only supports gzip.

Here is my JSON:

 

[
	{
		"email":"email@domain.com"
	}
]

 

 

Here is my ASP/VB code (authentication codes replaced) which uses Chilkat Software http component to send/receive data:

 

set obj=server.CreateObject("Chilkat_9_5_0.Http")
obj.UnlockComponent "softwarelicensehere"

set httpreq=server.CreateObject("Chilkat_9_5_0.HttpRequest")
set http=server.CreateObject("Chilkat_9_5_0.Http")

call http.SetRequestHeader("Authorization", "Bearer accesstokenhere")
call http.SetRequestHeader("Accept", "application/json")

set resp=http.PostJson2("https://api.constantcontact.com/v2/contacts?email=" & server.urlencode("email@domain.com") & "&status=ALL&limit=50&api_key=apikeyhere", "application/json", json)

 

 

I get this returned:

 

[{"error_key":"http.header.content_encoding.invalid","error_message":"Invalid content encoding type. API only supports gzip."}]

 

I'm not sure where this is going wrong. Do I need to contact Chilkat Software? Or is there something wrong with my code and/or how Constant Contact API is interpreting it?

 

Also, my JSON doesn't contain any data that isn't already in the URL query string. Is it necessary?

 

Thank you.

 

 

2 REPLIES 2
Moderator

Re: Error: Invalid content encoding type. API only supports gzip.

Hello,

 

 

I'm not personally familiar with Chilkat so my ability to provide you with specific guidance on how to form your HTTP request is limited.

 

Having said that, it looks like you are using some kind of method that is designed to make a POST call. POST calls are is used to give information to Constant Contact through the API. Examples would be creating a new contact, or making a new list. These are the types of calls where a JSON body is needed, as that is where you would place the information you are creating. And you would include a Content-Type header indicating that your request contains JSON. It would likely look like this:

call http.SetRequestHeader("Content-Type", "application/json")

 

The URL and parameters you are using are designed for a GET call, which is used to request information from our API, such as requesting a contact with a specific email address. GET calls do not have a body/payload/JSON. Because you don't include a body for a GET request, you don't need to set a header like above, and the response you get back will be in JSON as described in our documentation here: http://developer.constantcontact.com/docs/contacts-api/contacts-collection.html?method=GET


Please let me know if you have any other questions!

 

Regards,
David B.
Tier II API Support Engineer

Occasional Contributor

Re: Error: Invalid content encoding type. API only supports gzip.

Great, thank you. With that information, I was able to successfully do a GET request to pull up contact info. I'll be moving on to adding contact info next, using POST! Thanks again.