Skip to content

Instantly share code, notes, and snippets.

@jdmills-edu
Created October 10, 2017 02:55
Show Gist options
  • Save jdmills-edu/e0708258a563e5fab775389c6f0bf94e to your computer and use it in GitHub Desktop.
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 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