Forum Discussion

bob57's avatar
bob57
Helper IV
3 years ago

Getting Data From Toggle Time Tracker and Pagination

Hello,

I've been tasked with getting all time entries from Toggle into Power Bi. Problem: Only 50 records are returned. Does anyone have experience with this and know how to retrieve all records? Or is there another preferred method? Below is the query and a link to the API documentation.

Thank you,

Bob

 

API Doc: https://developers.track.toggl.com/docs/

 

let
baseUrl = "https://api.track.toggl.com/",
// the token part can vary depending on the requisites of the API
accessToken = "Basic Mzg2MzQ1NGFlZGU3Nzg3YWE5MzE0ZjU0ZGU4NmRkNjk6YXBpX3Rva2Vu",
postData = Json.FromValue([start_date = #date(2023,1,1)]),
options = [
Headers = [Authorization = accessToken, #"Content-Type" =
"application/json;"], RelativePath ="reports/api/v3/workspace/{workspace_id}/search/time_entries",
Content = postData
],
Source = Web.Contents(baseUrl, options),
// since Web.Contents() doesn't parse the binaries it fetches, you must use another
// function to see if the data was retreived, based on the datatype of the data
parsedData = Json.Document(Source)
in
parsedData

 

2 Replies

  • ppm1's avatar
    ppm1
    Solution Sage

    Looking at the Project page of that site shows at least that API method supports pagination.

     

     

    Perhaps the Workspaces one does too. You can either try it with pagination and List.Generate, or create a list of ids to be used as a start id for the next 50 records, as described in this video.

    Power BI - Tales From The Front - REST APIs - YouTube

     

    Pat

     

    • bob57's avatar
      bob57
      Helper IV

      Thank you for taking the time to respond. What I learned:

      1) /pagination is not supported with Workspaces.

      2) The video was very informative and I learned from viewing it, but I haven't found a way for the total number of records to be returned, so I'm not sure that creating a list of ids in a multiple of 50 would offer benefit.

      Again, thank you for your time. My search continues.

      Bob