Hi Guys,
I am trying to export responses from Qualtrics to PowerBI. I am totally new to this API concept. I downloaded some code from Github and put together the below code. Unfortunately the python code not working and I see there is some issue with the URL. Can you please help / advise.
import requests
import zipfile
import io
import os
def get_qualtrics_survey(dir_save_survey, survey_id):
# user Parameters
api_token = "XXXX"
file_format = "csv"
survey_id = "SV_2gwpQ5QDawpuFEO"
data_center = "XXXX"
# static parameters
request_check_progress = 0
progress_status = "in progress"
#base_url = "https://iad1.qualtrics.com/API/V3/surveys/SV_2gwpQ5QDawpuFEO/export-responses/".format(data_center)
base_url = "https://iad1.qualtrics.com/API/v3/survey_id/export-responses"
headers = {
"content-type": "application/json",
"x-api-token": api_token,
}
# Data Export
download_request_url = base_url
download_request_payload = '{"format":"' + file_format + '","surveyId":"' + survey_id + '"}' # you can set useLabels:True to get responses in text format
download_request_response = requests.request("POST", download_request_url, data=download_request_payload, headers=headers)
progress_id = download_request_response.json()["result"]["id"]
# print(download_request_response.text)
# Checking on Data Export Progress and waiting until export is ready
while request_check_progress < 100 and progress_status != "complete":
request_check_url = base_url + progress_id
request_check_response = requests.request("GET", request_check_url, headers=headers)
request_check_progress = request_check_response.json()["result"]["percentComplete"]
# Step 3: Downloading file
request_download_url = base_url + progress_id + '/file'
request_download = requests.request("GET", request_download_url, headers=headers, stream=True)
# Step 4: Unzipping the file
zipfile.ZipFile(io.BytesIO(request_download.content)).extractall(dir_save_survey)
print('Downloaded qualtrics survey')
path = "c:/Users/juliafx1/OneDrive - Abbott/Python/"
get_qualtrics_survey(dir_save_survey = path, survey_id = survey_id)
Question
Connecting Qualtrics to PowerBi
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
