0

I am receiving 403 error from search api when using this query:

"सार्वजनिक स्वास्थ्य जॉन्स हॉपकिन्स विश्वविद्यालय" OR "एमए एन ए पौष्टिक सहायता उत्पाद निगम" OR "मेडिसिन्स सैंस फ्रंटियर्स"

Error I have got from Twitter's api is:

{exceptionCode=[8e13056f-6071abbc], statusCode=403, message=Missing or invalid url parameter., code=195, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=447, limit=450, resetTimeInSeconds=1464249586, secondsUntilReset=695}, version=4.0.1}

It is strange because if I cut any element from original query it works.

The request I send is: https://api.twitter.com/1.1/search/tweets.json?q=%22%E0%A4%B8%E0%A4%BE%E0%A4%B0%E0%A5%8D%E0%A4%B5%E0%A4%9C%E0%A4%A8%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A5%8D%E0%A4%B5%E0%A4%BE%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A5%8D%E0%A4%AF%20%E0%A4%9C%E0%A5%89%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B9%E0%A5%89%E0%A4%AA%E0%A4%95%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B5%E0%A4%BF%E0%A4%B6%E0%A5%8D%E0%A4%B5%E0%A4%B5%E0%A4%BF%E0%A4%A6%E0%A5%8D%E0%A4%AF%E0%A4%BE%E0%A4%B2%E0%A4%AF%22%20OR%20%22%E0%A4%8F%E0%A4%AE%E0%A4%8F%20%E0%A4%8F%E0%A4%A8%20%E0%A4%8F%20%E0%A4%AA%E0%A5%8C%E0%A4%B7%E0%A5%8D%E0%A4%9F%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A4%B9%E0%A4%BE%E0%A4%AF%E0%A4%A4%E0%A4%BE%20%E0%A4%89%E0%A4%A4%E0%A5%8D%E0%A4%AA%E0%A4%BE%E0%A4%A6%20%E0%A4%A8%E0%A4%BF%E0%A4%97%E0%A4%AE%22%20OR%20%22%E0%A4%AE%E0%A5%87%E0%A4%A1%E0%A4%BF%E0%A4%B8%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B8%E0%A5%88%E0%A4%82%E0%A4%B8%20%E0%A4%AB%E0%A5%8D%E0%A4%B0%E0%A4%82%E0%A4%9F%E0%A4%BF%E0%A4%AF%E0%A4%B0%E0%A5%8D%E0%A4%B8%22&count=100&since=2016-05-23&with_twitter_user_id=true&include_entities=true

Do you have any idea what is wrong?

Piotr Idzikowski
  • 713
  • 5
  • 13

1 Answers1

0

You just hit a query limit, you can get similar failures with even a simple repeated A OR B query once it gets over the max length.

https://dev.twitter.com/rest/reference/get/search/tweets

q: A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity.

Since you want an OR, you should probably query 3 times and union the results in your code.

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
  • This would be a better answer if you suggested a solution. – Luke Taylor Jun 01 '16 at 01:40
  • 1
    There isn't a good solution that I'm aware of apart from doing the OR yourself. But I've now suggested that. – Yuri Schimke Jun 01 '16 at 01:49
  • The edit does a good job of satisfying that. Thanks, it's a much better answer now. – Luke Taylor Jun 01 '16 at 01:50
  • Well, that is the question what it means. If it is 500 chars of query or 500 chars of encoded query, The query has 122 character but when encoded it is 934 chars. On the other hand the limitation of the encoded query doesn't make any sense for me. – Piotr Idzikowski Jun 01 '16 at 10:24
  • Well you can experiment to find exactly where it breaks and which one it is. Then post that as a better answer to your own question. – Yuri Schimke Jun 01 '16 at 13:54
  • Well of course I did some experiments. But it doesn't solve my problem as I'd prefer to know the rule to split it. Any method I used (bytes, chars, codepoints, chars in url-encoded query) doesn't agree with 500 chars limit pointed in the Twitter documentation. – Piotr Idzikowski Jun 22 '16 at 13:09