I'm brand new to working with the SurveyMonkey API, and relatively new to Python/API work in general. I'm trying to build a very simple program that will, for starters, pull the list of surveys on my SurveyMonkey account.
Here's what I'm starting with:
import requests
import json
client = requests.session()
client.headers = {
"Authorization": "bearer %s" % "<MY_ACCESS_TOKEN>",
"Content-Type": "application/json"
}
client.params = {
"api_key" : "<MY_API_KEY>"
}
HOST = "https://api.surveymonkey.net"
SURVEY_LIST_ENDPOINT = "/v3/surveys/get_survey_list"
uri = "%s%s" % (HOST, SURVEY_LIST_ENDPOINT)
data = {}
response = client.get(uri, data=json.dumps(data))
response_json = response.json()
survey_list = response_json["data"]["surveys"]
When run, this code results in the following error:
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
Any ideas on where I'm going wrong? Any help is much appreciated!
The endpoint you were using/v3/surveys/get_survey_list
does not exist in V3, it does exist in V2 (/v2/surveys/get_survey_list
).
See here for get survey list in v3. Try something like:
import requests
client = requests.session()
headers = {
"Authorization": "bearer %s" % "<MY_ACCESS_TOKEN>",
"Content-Type": "application/json"
}
params = {
"api_key" : "<MY_API_KEY>"
}
HOST = "https://api.surveymonkey.net"
SURVEY_LIST_ENDPOINT = "/v3/surveys"
uri = "%s%s" % (HOST, SURVEY_LIST_ENDPOINT)
response = client.get(uri, params=params, headers=headers)
response_json = response.json()
survey_list = response_json["data"]["surveys"]