Using the gc.exe command line application. Start by setting your region, oauth clientid and clientsecret variables. Then get the list of data tables from the API.
$varResponse = .\gc.exe flows datatables list -a --clientid $ClientId --clientsecret $ClientSecret --environment $Region -i --outputformat JSON --profile gc-cli | ConvertFrom-Json
Then loop through the response objects.
$varDataTableJob = .\gc.exe flows datatables export jobs create $($_.id) --clientid $ClientId --clientsecret $ClientSecret --environment $Region --outputformat JSON --profile gc-cli | ConvertFrom-Json
Use a Do{this operation} Until{this condition is met} to query the below API, with a 5 second pause.
$varDataTableStatus = .\gc.exe flows datatables export jobs get $($_.id) $($varDataTableJob.id) --clientid $ClientId --clientsecret $ClientSecret --environment $Region --outputformat JSON --profile gc-cli | ConvertFrom-Json
You can then use the downloadURI from the response to download the file. I set $varDownloadID = $varDataTableStatus.downloadURI
Set your $filepath (save directory + filename) variable.
$varfile = .\gc.exe downloads get $($varDownloadID) --issueRedirect=false --clientid $ClientId --clientsecret $ClientSecret --environment $Region --profile gc-cli | ConvertFrom-Json
I then leveraged a PS System.Net.WebClient operation to download the file with a $varfile.url and $filepath that I set in my script. Keep in mind this WebClient operation can be unreliable with downloading files, giving the script a false-positive response that it saved the file when it didn't actually save. To overcome this problem I placed the WebClient portion into a Do{this} Until{this condition is met} operation. To keep attempting to download the data table until the $filepath is true.
End of loop.
------------------------------
Carlos Albor
Principal PS Consultant
------------------------------
Original Message:
Sent: 02-12-2025 23:49
From: Matsumoto Shun
Subject: Automatic export of data tables
Hello Everyone
I understand that it is possible to export data manually by selecting the target data table and clicking the "Export Data" button.
This time, I am looking for a way to export data automatically, rather than manually.
Specifically, I would like to export a specific data table automatically at 13:00 every day.
I would like some advice, including whether this is possible or not.
Best regards,
#API/Integrations
#ArchitectureandDesign
#Reporting/Analytics
------------------------------
Matsumoto Shun
Unknown
------------------------------