Skip to content

Instantly share code, notes, and snippets.

@phillypb
Created August 18, 2022 08:02
Show Gist options
  • Save phillypb/0dea36b65d6935450fbfad1fc8a79966 to your computer and use it in GitHub Desktop.
Save phillypb/0dea36b65d6935450fbfad1fc8a79966 to your computer and use it in GitHub Desktop.
/*
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