Tableau Prep – Connecting to REST API
Tableau Prep or Tableau does not have A built in rest API connector, but we can download data from rest API using Power Shell and pass it to Tableau Prep Flow.
We will be using IEX Share price API for the purpose of this demonstration. Try the below one liner in your command tine and see the results. (This end point provides last 3 month share prices of Apple).
powershell.exe "Invoke-RestMethod 'https://api.iextrading.com/1.0/stock/aapl/chart/3m'"
If your rest endpoint requires authentication or custom headers, ‘Invoke-RestMethod’ cmdlet have options to handle that too.
Here is the complete script to download data, convert to csv and run the flow
powershell.exe "(Invoke-RestMethod 'https://api.iextrading.com/1.0/stock/aapl/chart/3m')|Export-Csv -Path 'C:/Automation/rest_data.csv' -NoTypeInformation"
call "C:\Program Files\Tableau\Tableau Prep 2019.1\scripts\tableau-prep-cli.bat" -t "C:\Automation\rest.tfl"