How to access Clockify API through Power Query

后端 未结 2 355
独厮守ぢ
独厮守ぢ 2021-01-27 05:34

I am trying to get my time entries from Clockify API directly via Power Query to Excel. I use the following code in the Power Query:

= Web.Contents(\"https://api         


        
相关标签:
2条回答
  • 2021-01-27 06:07

    There are two things to keep in mind when making calls to REST-based APIs in Power Query/M:

    1. When using the Web.Contents() function, it's best to pass your API key as a parameter within the request header itself. In your case X-Api-Key should equal to {your API key}.

    2. Use anonymous access to connect to the API. Your screenshot suggests you're trying to connect using "Web API". Clear the value in the "Schlüssel" field and use "Anonym" instead.

    Here's a simple example where I return the information about a workspace by workspace ID. (I've masked both my workspace ID and API key; replace these values with your workspace ID and API key.)

    This works for me in both Excel and Power BI:

    let
        Source = 
            Web.Contents(
                "https://api.clockify.me/api/workspaces/{your workspace ID}", 
                [
                    Headers=[
                        #"Content-Type"="application/json", 
                        #"X-Api-Key"={your API key}
                    ]
                ]
            ),
        jsonResponse = Json.Document(Source)
    in
        jsonResponse
    
    0 讨论(0)
  • 2021-01-27 06:11

    Doesn't it have to be X-Api-Key instead of ApiKeyName?

    0 讨论(0)
提交回复
热议问题