I'm using python 3.6.4. Trying to retrieve data from Survey Monkey API using the following:
access_token = 'xxx'
collector_id = 'yyy'
s = requests.session()
s.headers.update({
"Authorization": "Bearer %s" % access_token,
"Content-Type": "application/json"
})
url = "https://api.surveymonkey.com/v3/collectors/%s/responses/bulk?start_created_at=2020-
02-11T23:20:00+00:00" % (collector_id)
res = s.get(url)
dat = res.json()
Unfortunately this leads to the following error:
{'error': {'id': '1003',
'name': 'Bad Request',
'docs': 'https://developer.surveymonkey.com/api/v3/#error-codes',
'message': 'Invalid URL parameters.',
'http_status_code': 400}}
I found a post that addresses the same issue as here but the solutions provided there didn't work for me. Here is the post: start_created_at not working with /collectors/{id}/responses
Can someone point me in the right direction regarding how I can format the query string so that my URL parameter I'd like to filter by is valid?
You need to URL encode only the date/time portion of the URL. Try this:
timedate = '2020-02-11T23:20:00+00:00'
timedate_enc = urllib.parse.quote(timedate)
url = 'https://api.surveymonkey.com/v3/collectors/%s/responses/bulk?start_created_at=%s' % (collector_id, timedate_enc)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.