Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Griggs
Frequent Visitor

POST API - Web.Contents failed to get contents

I have the following query that is working fine in Power BI desktop (I have anonymised the API Key and Workspace ID in the relative path). However, when publised, I am getting an error:Failed to update data source credentials: Web.Contents failed to get contents from 'https://reports.api.clockify.me/' (404): Not Found
Is there any way round this?

let
    // Inline dynamic date range: last 365 days
    todayDate = DateTime.Date(DateTime.LocalNow()),
    startDate = Date.ToText(Date.AddDays(todayDate, -365), "yyyy-MM-dd") & "T00:00:00Z",
    endDate = Date.ToText(todayDate, "yyyy-MM-dd") & "T23:59:59.999Z",

    // API credentials and endpoint parts
    apiKey = "-",
    baseUrl = "https://reports.api.clockify.me",  
    relativePath = "v1/workspaces/-/reports/detailed",

    // JSON request body
    requestBody = [
        dateRangeStart = startDate,
        dateRangeEnd = endDate,
        exportType = "JSON",
        detailedFilter = [
            page = 1,
            pageSize = 1000
        ]
    ],
    binaryBody = Json.FromValue(requestBody),

    // API call
    response = Web.Contents(baseUrl, [
        RelativePath = relativePath,
        Headers = [
            #"X-Api-Key" = apiKey,
            #"Content-Type" = "application/json"
        ],
        Content = binaryBody
    ]),

    // Parse and transform response
    json = Json.Document(response),
    entries = json[timeentries],
    table = Table.FromList(entries, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    output = Table.ExpandRecordColumn(table, "Column1", {
        "_id", "description", "userId", "timeInterval", "billable", "projectId", "taskId", "tagIds",
        "approvalRequestId", "type", "isLocked", "currency", "amount", "rate", "earnedAmount",
        "earnedRate", "costAmount", "costRate", "projectName", "projectColor", "clientName",
        "clientId", "taskName", "userName", "userEmail"
    })
in
    output

 

1 REPLY 1
OwenAuger
Super User
Super User

Hi @Griggs

I took your query and added my own Clockify API Key & Workspace ID, and initially received the same error when setting up Data Source Credentials in the Power BI Service.

 

After some testing, it seems the only way to avoid the error and validate the Data source credentials is to bypass the connection test by enabling "Skip test connection" as shown here:

OwenAuger_0-1751113078862.png

This seems to be one of those cases where the Power BI Service simply can't validate the API URL. Changing the split between Base & Relative URLs didn't seem to help in this case.

 

In any case, after enabling "Skip test connection", I was able to successfully refresh the semantic model in the Service.

 

Are you also able to get refresh working in the same way?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.