Calling Twitter API returns an error

I am using an HTTP request node for the twitter API, for the following historical data endpoint: POST insights/engagement | Docs | Twitter Developer Platform

https://data-api.twitter.com/insights/engagement/historical

However, I am receiving an error message from twitter: {“errors”:[“This request requires gzip compression. Retry the request after setting ‘Accept-Encoding’ header in the request to ‘gzip’.”]}

But I have set the header Accept-Encoding : gzip
It looks like the node doesn’t send the header to twitter - is that possible?

Best,
Boris

Hi @Boris_Idesman - I had a peek there at your workflow and webhook.site accepts the exact same header encoding you’re using:

Could you let us know what version of n8n you’re using? Also, does this request work by chance via CURL?

2 Likes

The version of n8n is 0.225.2
I have not tested via CURL because I use the n8n twitter authentication.
But other calls to the twitter API with the same credentials work, like for example calling: https://api.twitter.com/2/users/{user_id}/followers?user.fields=profile_image_url&max_results=3

I used webhook.site after pulling that particular version of n8n and the headers are still being sent as they should:
image

You may need to reach out to Twitter support and ask them to clarify exactly what they expect and what they mean with that error message, as it looks to be misleading since n8n is sending those headers as you’ve specified. :see_no_evil:

1 Like

And do you get the same error?
I tried with CURL and it worked out.

Hi @Boris_Idesman - can you send both requests to a test url from webhook.site and see if there are any noticeable differences between what n8n is sending and what cURL is sending?

Sorry what do you mean by “webhook.site”

webhook.site is a free webhook testing website - you can use it to test these requests and see the difference between them :+1:

I don’t think that helps, as we don’t want to expose our API keys.
Please let me know if you observe the same issue as I do.
Thanks.

Hey @Boris_Idesman,

You can send the request to webhook.site after removing the credential this would help confirm if the header is being sent like we are seeing.

@Jon I think the issue comes from the Enterprise API of twitter, not being enabled.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.