Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi All
Very new to Power BI but slowly figuring things out. I have a json API source that currently uses a web source and Basic authentication via the Data Source GUI. This works great.
Username: <API Key>
Password: Blank
I would like to set the API key as a parameter and reference it in a query instead of using the GUI - Something like below (with FreshserviceAuthHeader as the parameter):
(PageNo as number) =>
let
Source = Json.Document(Web.Contents(FreshserviceBaseURL,
[RelativePath="/tickets?",
Query=[workspace_id="2",
page=Number.ToText(PageNo),
Headers=[Authorization="Basic "&FreshserviceAuthHeader]]))
in
Source
But this doesn't work. Is this technically possible?
Thanks
Solved! Go to Solution.
change your data source settings to anonymous auth.
no, the ) afterwards.
That was a typo in my post. Heres what it currently looks like:
let
Source = Json.Document(Web.Contents(FreshserviceBaseURL,
[RelativePath="tickets",
Headers=[Authorization="Basic " & FreshserviceAuthHeader]]))
in
Source
change your data source settings to anonymous auth.
Ok, Looking at this with fresh eyes, setting to anonymous auth does do the trick. Thank you for your help!
RelativePath must be only "tickets"
Usually an APIKey is part of the URL but consult the documentation of your API for the details. Spacing is important so use
Headers=[Authorization="Basic " & FreshserviceAuthHeader]
Thanks for your help. I went back to the API documentation and found this article detailing how to connect via powershell.
Running that powershell script with the Base64 key works (and i can get data from the API).
$credPair = "<your-freshservice-api-token>:.";
$encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credPair));
$headers = @{ Authorization = "Basic $encodedCredentials" };
$url = "https://<your-subdomain>.freshservice.com/api/v2/tickets/1?include=assets";
$Response = Invoke-WebRequest -Uri $url -Method Get -Headers $headers -UseBasicParsing;
$Response.Content;
The format for the headers line matches what you suggested and what i have in my query but i get the following error:
Show the definition of FreshServiceBaseURL
I have tested omitting the variable, instead inserting the API straight into the query like below but no dice.
Headers=[Authorization="Basic <Base64encoded APIKEY>)"]
The value of the Parameter is:
Basic <Base64encoded API Key>
is that extra parenthesis a typo?
are you reffering to the <> charecters? They were for illistrutive purposes and not actually in use - sorry for conufusion
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
26 | |
25 | |
24 | |
13 | |
10 |
User | Count |
---|---|
24 | |
21 | |
18 | |
17 | |
10 |