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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

GET Request for an API with Authentication

So I need to create an API connection to Personio (a company Human Resource tool), where I obtain specific data about employees.

I have a Client-ID for that API, as well as a API-Secret (which I assume is the API Key). Also, I have done some minor previous work with API connection to Jira and NewRelic, both methods dont work here.

 

A reason for this is what a developer told me, that first an authentication needs to take place, before the data can be requested. Meaning that there is 2 different enpoints which need to connected to according to the Personio documentation.

I have listed their POSTMAN information below of how the authentication runs and then the custom attribute endpoint.

 

I need to get that data into PowerBI somehow and would truly appreciate any help here. I have already gone through the forums to test various answers on API connections, but no success.

 

Thank you to anyone who can help here!

 

Personio POSTMAN Documentation:

"item": [
                {
                        "name": "Authentication",
                        "item": [
                                {
                                        "name": "Auth Endpoint",
                                        "event": [
                                                {
                                                        "listen": "test",
                                                        "script": {
                                                                "exec": [
                                                                        "var data = pm.response.json();",
                                                                        "var token = data.data.token;",
                                                                        "",
                                                                        "if (token) {",
                                                                        "    pm.environment.set(\"authToken\", token);",
                                                                        "}"
                                                                ],
                                                                "type": "text/javascript"
                                                        }
                                                }
                                        ],
                                        "request": {
                                                "auth": {
                                                        "type": "noauth"
                                                },
                                                "method": "POST",
                                                "header": [],
                                                "url": {
                                                        "raw": "https://api.personio.de/v1/auth?client_id=XXXXX&client_secret=XXXXX",
                                                        "protocol": "https",
                                                        "host": [
                                                                "api",
                                                                "personio",
                                                                "de"
                                                        ],
                                                        "path": [
                                                                "v1",
                                                                "auth"
                                                        ],
                                                        "query": [
                                                                {
                                                                        "key": "client_id",
                                                                        "value": "XXXXX"
                                                                },
                                                                {
                                                                        "key": "client_secret",
                                                                        "value": "XXXXX"
                                                                }
                                                        ]
                                                }
                                        },
                                        "response": []
                                }
                        ]

 

 

 

"name": "Get All Custom Attributes",
                                        "event": [
                                                {
                                                        "listen": "test",
                                                        "script": {
                                                                "exec": [
                                                                        "var authHeader = pm.response.headers.get(\"authorization\");",
                                                                        "",
                                                                        "if (authHeader) {",
                                                                        "    pm.environment.set(\"authToken\", authHeader.substring(7));",
                                                                        "}"
                                                                ],
                                                                "type": "text/javascript"
                                                        }
                                                }
                                        ],
                                        "request": {
                                                "method": "GET",
                                                "header": [],
                                                "url": {
                                                        "raw": "https://api.personio.de/v1/company/employees/custom-attributes",
                                                        "protocol": "https",
                                                        "host": [
                                                                "api",
                                                                "personio",
                                                                "de"
                                                        ],
                                                        "path": [
                                                                "v1",
                                                                "company",
                                                                "employees",
                                                                "custom-attributes"
                                                        ]
                                                }
                                        },
                                        "response": []
                                },
                                {
                                        "name": "Get All Attributes",
                                        "event": [
                                                {
                                                        "listen": "test",
                                                        "script": {
                                                                "exec": [
                                                                        "var authHeader = pm.response.headers.get(\"authorization\");",
                                                                        "",
                                                                        "if (authHeader) {",
                                                                        "    pm.environment.set(\"authToken\", authHeader.substring(7));",
                                                                        "}"
                                                                ],
                                                                "type": "text/javascript"
                                                        }
                                                }
                                        ]

 

3 REPLIES 3
Anonymous
Not applicable
Anonymous
Not applicable

Hi @Anonymous ,

Please try:

let
    GetAccessToken = () =>
    let
        url = "https://api.personio.de/v1/auth",
        body = Text.ToBinary("{""client_id"":""YOUR_CLIENT_ID"",""client_secret"":""YOUR_API_SECRET""}"),
        headers = [#"Content-Type" = "application/json"],
        response = Json.Document(Web.Contents(url, [Headers=headers, Content=body])),
        token = response[access_token]
    in
        token,

    FetchData = () =>
    let
        accessToken = GetAccessToken(),
        url = "https://api.personio.de/v1/custom-attributes",
        headers = [#"Authorization" = "Bearer " & accessToken],
        response = Json.Document(Web.Contents(url, [Headers=headers]))
    in
        response,

    // Call the FetchData function to retrieve the data
    Source = FetchData()
in
    Source

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Anonymous
Not applicable

That definitely gets me further than before. I used "Anonymous" as credential option to connect, but still got the following error: (red marking is the API secret)

Spartan_0-1717657465866.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.