9 Replies Latest reply on Oct 16, 2018 3:19 AM by Karsten Henow

    Multiple getJSON calls in a WDC

    Graeme Ord

      Hi,

       

      I have written a Web Data Connector that queries an API and gets data for a year that is passed in via the URL.  All good and working

       

      However, I want to extend the API to get more than one years worth of data but the way the API is structured, I would need to make multiple calls to this in the URL - one url string per year therefore one getJSON call per year.

       

      I have tried wrapping the calls into a for loop and running the call for every year between a start and end range, building each url string fro the GetJSON based on the value in the variable in the for.  This works fine in the simulator where - I believe - it is just responding to the AppendRows call.  When I run this in Tableau Desktop, it only ever gets one year of data and then exits.  As far as I understand, this is because the doneCallBack(); has to be ran after table.appendRows();  and I think it is showing the first getJSON call that has asynchronously called back to the script

       

      i.e.

       

              table.appendRows(tableData);

              doneCallback();

       

      If I move the doneCallBack() outside of the for loop, the WDC does not bring any data back.

       

      So, has anyone got something like this to work where data is comprised of multiple calls to the same API within the WDC javascript?

       

      It is especially annoying that I thought I had this working in the simulator but in desktop not - that made me sad

       

      Looking forward to hearing if anyone has come across this and found a resolution.

       

      Graeme