Hi Holger,
Thank you very much for your assistance and providing a sample of your work, I really appreciate it.
I managed (after a lot of trial and error) to get Postman to build a request that worked for me and then started messing around with the Power Query to get it to do what I wanted. It is mostly there at this stage.
I am a firm believer in sharing knowledge with the masses, to better educate and in the hopes it might help someone else who is having the same issues I am, so here is what I managed to get working:
let
yesterdayStart = DateTime.ToText(DateTime.LocalNow() - #duration(365+1,0,0,0), “yyyy-MM-ddT00:00:00.000Z”),
yesterdayEnd = DateTime.ToText(DateTime.LocalNow()-#duration(1,0,0,0), “yyyy-MM-ddT23:59:59.999Z”),
url = “https://reports.api.clockify.me/v1/workspaces/[WORKSPACE.ID]/reports/detailed”,
body = Text.ToBinary(“{ ““dateRangeStart””: “”” & yesterdayStart & “”“,”“dateRangeEnd”“: “”” & yesterdayEnd & “”“, ““detailedFilter””: { ““page””: 1, ““pageSize””: 50 }, ““exportType””: ““CSV”” }”),
headers = [
#“Content-Type” = “application/json”,
#“X-Api-Key” = “[YOUR.API.KEY]”
],
response = Web.Contents(url, [Headers=headers, Content=body]),
jsonResponse = Csv.Document(response)
in
jsonResponse
This is the power query that I have been using to reproduce the .csv export I get whenever I use the Detailed report export function on the website. For now it is just pulling in data for the past year.
My end goal would be to have some form of a user defined variable that they can input (maybe via cell in one of the sheets) and it pulls the data via the API. This should allow us to get all of out time entries filtered on by the project code, rather than a time frame as shown above.
But that will be the next iteration, for now this is workable.
Again, thanks very much for sharing, I will probably use some of your query to help build the next phase of mine.
Cheers
Ian