1
votes

Im quite new to http request. Im having abit of troubleshooting trying to get survey results/responses from survey monkey api 3.

Here is the following code i have:

import requests
import json

client = requests.session()

headers = {
    "Authorization": "bearer %s" % "VVZEO3u35o3JVDdd8z5Qhl-eRR5Er2igaV1gf8GS4dvRfYVk3SWu9nHginwyNnU.tAHEr-AtikR9Zpg7vL3-jIg3-6yuQkPBvVIw0AkpYN5807SCLIrGojsii3ihdGV-",
    "Content-Type": "application/json"
}

data = {}

HOST = "https://api.surveymonkey.net"
#SURVEY_LIST_ENDPOINT = "/v3/surveys/%s/responses/%s/details" %("85160626","161")
SURVEY_LIST_ENDPOINT = "/v3/surveys/85160626/responses"

uri = "%s%s" % (HOST, SURVEY_LIST_ENDPOINT)

response = client.post(uri, headers=headers, data=json.dumps(data))

response_json = response.json()
#survey_list = response_json["data"]["surveys"]

print(response_json)

I keep getting error:

{'error': {'docs': 'https://developer.surveymonkey.com/api/v3/#error-codes', 'message': 'There was an error retrieving the requested resource.', 'id': '1020', 'name': 'Resource Not Found', 'http_status_code': 404}}

Any help is much appreciated, thanks, Pon

1
Pon Yuntawai you should remove the access token if that's your real one as it gives people access to your account (like a password) - General Kandalaft

1 Answers

2
votes

If you're trying to fetch data, then you should be doing a GET request, not a post.

response = client.get(uri, headers=headers)

Otherwise it looks fine, just make sure the Survey ID is correct.