<exec>
# Set up API headers with your Aftercare API key
p.api_headers = {
"X-Aftercare-Key": "<AFTERCARE API KEY>",
"Content-Type": "application/json"
}
# Get the questions and responses from your survey. You can evaluate multiple answers from the respondent at once
p.survey_entries = []
p.survey_entries.append({
"question": TopicQuestion1.title, # The question that was asked to the respondent
"answer": TopicQuestion1.val, # The answer to the question provided by the respondent
"questionIdentifier": "q1", # Optional unique identifier for the question
})
p.survey_entries.append({
"question": TopicQuestion2.title,
"answer": TopicQuestion2.val,
"questionIdentifier": "q2",
})
# Prepare the API request body
p.api_data = '{
"surveyName": "<Your Survey Name>", # The name of the survey as it will appear in the Aftercare platform
"surveyDescription": "<Description of your survey>", # Description of the survey purpose and background
"surveyIdentifier": "survey_123", # Optional unique identifier for the survey
"responseIdentifier": "resp_123", # Optional unique identifier for a respondent's entire response
"surveyEntries": [
{
"question": "' + p.survey_entries[0]["question"] + '",
"answer": "' + p.survey_entries[0]["answer"] + '",
"questionIdentifier": "' + p.survey_entries[0]["questionIdentifier"] + '",
},
{
"question": "' + p.survey_entries[1]["question"] + '",
"answer": "' + p.survey_entries[1]["answer"] + '",
"questionIdentifier": "' + p.survey_entries[1]["questionIdentifier"] + '",
}
]
}'
</exec>