Created
August 18, 2022 08:02
-
-
Save phillypb/0dea36b65d6935450fbfad1fc8a79966 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
Get Survey - https://api.qualtrics.com/73d7e07ec68b2-get-survey | |
*/ | |
function getSurveyDetails() { | |
// Qualtrics API Token: Qualtrics > Account Settings > Qualtrics IDs > API Token | |
var apiToken = 'YOUR API TOKEN HERE'; | |
// ID of Survey to export details from | |
var surveyId = 'YOUR SURVEY ID HERE'; | |
// Data Center ID | |
var dataCenterId = 'YOUR DATA CENTER ID'; | |
// Qualtrics API Url | |
var baseUrl = 'https://' + dataCenterId + '.qualtrics.com/API/v3/surveys/' + surveyId; | |
Logger.log('baseUrl is: ' + baseUrl); | |
// authentication headers | |
var headers = { | |
"x-api-token": apiToken | |
}; | |
// compile the above options | |
var options = { | |
'method': 'get', | |
'headers': headers | |
}; | |
// get response from API | |
var request = UrlFetchApp.fetch(baseUrl, options); | |
// extract API response data | |
var resultText = request.getContentText(); | |
var resultObj = JSON.parse(resultText); | |
Logger.log(resultObj); | |
// get Survey name | |
var surveyName = resultObj['result']['name']; | |
Logger.log('Survey name is: ' + surveyName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment