I'm working on an app that makes a request to the SE API over HTTP. The app works fine until the 300th request.
I requested/received an API key, but once I append it to the URL, I start receiving errors.
[(u'error_id', 400), (u'error_message', u'fromdate'), (u'error_name', u'bad_parameter')]
It appears to be telling me the fromdate
parameter is invalid, but the query works fine until I add the key.
What am I doing wrong here?
Code as requested:
import urllib
import json
from datetime import date,timedelta
from time import sleep
import zlib
burl = 'https://api.stackexchange.com/2.2/search/advanced?&'
apiKey = "$KEY_VALUE"
langList = ['python', 'r', 'SAS']
for lang in langList:
#paramsList = [('fromdate', "2017-02-15"), ('todate', "2017-02-16"), ('order', 'desc'), ('tagged', lang), ('sort', 'activity'), ('site', 'stackoverflow'), ('filter', 'total'), ('key', apiKey)]
paramsList = [('fromdate', "2017-02-15"), ('todate', "2017-02-16"), ('order', 'desc'), ('tagged', lang), ('sort', 'activity'), ('site', 'stackoverflow'), ('filter', 'total')]
dailyUrl = burl + urllib.urlencode(paramsList)
print dailyUrl
dailyRes = json.loads(zlib.decompress(urllib.urlopen(dailyUrl).read(), 15 + 32))
print dailyRes.items()
The results are either:
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=python&sort=activity&site=stackoverflow&filter=total
[(u'total', 690)]
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=r&sort=activity&site=stackoverflow&filter=total
[(u'total', 227)]
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=SAS&sort=activity&site=stackoverflow&filter=total
[(u'total', 10)]
or
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=python&sort=activity&site=stackoverflow&filter=total&key=$KEY_VALUE
[(u'error_id', 400), (u'error_message', u'fromdate'), (u'error_name', u'bad_parameter')]
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=r&sort=activity&site=stackoverflow&filter=total&key=$KEY_VALUE
[(u'error_id', 400), (u'error_message', u'fromdate'), (u'error_name', u'bad_parameter')]
https://api.stackexchange.com/2.2/search/advanced?&fromdate=2017-02-15&todate=2017-02-16&order=desc&tagged=SAS&sort=activity&site=stackoverflow&filter=total&key=$KEY_VALUE
[(u'error_id', 400), (u'error_message', u'fromdate'), (u'error_name', u'bad_parameter')]