"Error code 195: Missing or invalid url parameter" when using search with max_id



I keep getting the above error (HTTP status code 403) when using the search API. I’m using Python with Tweepy’s Cursor which implements this algorithm: https://dev.twitter.com/rest/public/timelines. I also implemented it on my own and got the same error. It only happens with some of the queries I make.
Example failing query:

q: -RT (("Spectre" OR #Spectre) AND (film OR movie OR poster OR trailer OR bond OR "Daniel Craig" OR DanielCraig OR "Christoph Waltz" OR ChristophWaltz OR "Lea Seydoux" OR LeaSeydoux OR "Monica Bellucci" OR MonicaBellucci OR "Andrew Scott" OR AndrewScott OR "Dave Bautista" OR DaveBautista OR "Ralph Fiennes" OR RalphFiennes OR "Naomie Harris" OR NaomieHarris OR "Ben Whishaw" OR BenWhishaw OR "Rory Kinnear" OR RoryKinnear OR "007")) OR (("Spectre" OR #Spectre) AND (@007))
lang: en
max_id: 666389911482814466

which results in a following URL:

Tried it both using Tweepy and through https://dev.twitter.com/rest/tools/console. The result is the same.
The query length is well below the 1000 characters limit but maybe it’s still too complex? Removing a few of the ORs seems to help but I feel reluctant to call it a solution without some kind of confirmation.


I am not sure to have seen the 1000 char. limit. The limit for the q parameter is 500, is your query not overpassing this limit?
source: https://dev.twitter.com/rest/reference/get/search/tweets


Right, I can’t find that now either. Unfortunately all queries I’m making are below 500 characters.