Skip to content

Instantly share code, notes, and snippets.

@swbuehler
Created August 3, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swbuehler/4b632cb30d89bddea93aab3c39ae8ae1 to your computer and use it in GitHub Desktop.
Save swbuehler/4b632cb30d89bddea93aab3c39ae8ae1 to your computer and use it in GitHub Desktop.
Fetch trip logs from Automatic API (app registration required)
$results = @()
$headers = @{"Authorization" = "Bearer XXXXXXXXXX"}
$feed = Invoke-RestMethod -Uri "https://api.automatic.com/trip/" -Headers $headers
$next = $feed._metadata.next
while ($next -ne $null){
foreach ($result in $feed.results){
$results += $result
}
$feed = Invoke-RestMethod -Uri $next -Headers $headers
$next = $feed._metadata.next
}
$results | ConvertTo-Json | out-file "C:\Temp\automatictrips.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment