Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
15 | |
15 | |
13 | |
12 | |
11 |