Created
October 10, 2017 02:55
-
-
Save jdmills-edu/e0708258a563e5fab775389c6f0bf94e to your computer and use it in GitHub Desktop.
A PowerShell script that lists all surveys accessible to a Qualtrics user with an API token.
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
#This Qualtrics API call only returns surveys accessible to the user holding the token, not all surveys in the tenant. | |
#Define headers and API endpoint. | |
$headers = @{ | |
"X-API-TOKEN" = yourapitoken | |
} | |
$qualtrics_api_url = "https://yourdatacenter.qualtrics.com/API/v3" | |
$endpoint = "surveys" | |
$uri = $qualtrics_api_url+"/"+$endpoint | |
#Create an empty array and fill it. | |
$surveys = @() | |
$result = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers | |
$surveys += $result.result.elements | |
#If pagination is required, change the query URI to the nextPage property returned in the previous loop. | |
while($result.result.nextPage){ | |
$result = Invoke-RestMethod -Method Get -Uri $result.result.nextPage -Headers $headers | |
$surveys += $result.result.elements | |
Write-Host "." -NoNewline -ForegroundColor Green | |
} | |
return $surveys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment