-
-
Save zdenekmaxa/a5001b19ffe621aa247e4a13b4ed7b08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
QUALTRICS_TOKEN = "FILL IN HERE YOUR API ACCESS TOKEN" | |
QUALTRICS_API_URL = "https://eu.qualtrics.com/API/v3/" | |
API_CALL_HEADERS = { | |
"x-api-token": QUALTRICS_TOKEN, | |
"content-type": "application/json", | |
"Accept": "application/json" | |
} | |
url = QUALTRICS_API_URL + "survey-definitions" | |
survey_data = {"SurveyName": "New Survey Name 01", "Language": "EN", "ProjectCategory": "CORE"} | |
r = requests.post(url, json=survey_data, headers=API_CALL_HEADERS) | |
r.raise_for_status() | |
res = r.json()["result"] | |
print(f"Response survey create: {res}") | |
survey_id = res["SurveyID"] | |
url = QUALTRICS_API_URL + f"survey-definitions/{survey_id}/blocks/" | |
block_data = { | |
"Type": "Standard", | |
"Description": "New Block 01", | |
# options are dropped, not present in the newly created block | |
"Options": { | |
"BlockLocking": "false", | |
"RandomizeQuestions": "false", | |
"BlockVisibility": "Collapsed" | |
}, | |
} | |
r = requests.post(url, json=block_data, headers=API_CALL_HEADERS) | |
r.raise_for_status() | |
res = r.json()["result"] | |
print(f"Response block create: {res}") | |
block_id = res["BlockID"] | |
url = QUALTRICS_API_URL + f"survey-definitions/{survey_id}" | |
r = requests.get(url, headers=API_CALL_HEADERS) | |
res = r.json()["result"] | |
r.raise_for_status() | |
assert "Options" in res["Blocks"][block_id] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment