Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a function that I’ve created that works with a JSON api with a query
let Source = (RelativePath) =>
// function to add as a custom column to pull in relative path from table using the name of the api call
let
Source = Json.Document(Web.Contents(
“https:/********/”,
// url remains static
[
RelativePath = RelativePath,
Query =
[
token=Token // token is parameterised
]
]
)),
#“Converted to Table” = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#“Converted to Table”
in Source
Which works and I can add as a custom column to the table that holds the relative path within a column.
I’d like to try to do the same but using a url with a Headers field but am struggling.
The url is structured like this:
= Json.Document(Web.Contents(“https:///RelativePathstoredincolumn", [Headers=[#“X-SiteToken”="****”]]))
and I want to use a Headers parameter instead of query and token as above. I think it’s because it’s a list within a list and has special characters in it. Any suggestions?
//[Headers=[#"“X-SiteToken”"=""***********""]]))"
Solved! Go to Solution.
Hi Pat, I got it to work. I'd tried putting it in as a parameter before but had neglected to change the parameter to a list type! So now when I put it in as a custom function within the column, I could then specify which column to use as the input and therefore which row. A bit of an epic journey.
@ImkeF I got it to work and learnt a lot 🙂
Hi Imke,
Thank you for replying, really appreciate it.
Power BI and Json
I have a table that gives the name of the API call and two methods of calling the API.
Both work when I use them within a blank query but I want to create a function using create a custom function column that will use the value in the API Call to fill in the APICallName and run the function.
The query for API URL which works is
This allows me to add this into a column as a function, add an index, and expand using index number
Then I can use another function to Extract the Data by entering the index number
The customer would prefer to use the url using the Headers option in the second column but I’m struggling to get the parameterised code working.
This is my latest attempt but I think there must be something to do with the structure of the headers and it being a nested list with special objects in it. When I add this code into the column I get an error message that I argument was passed to a function which expects 2.
Have been trying all sorts of options, any thoughts would be gratefully appreciated.
Hopefully it makes a bit more sense,
Sue
It looks like you are putting the relative path into the body of the web call in the last image, instead of putting it in the relative path option of the Web.Contents function. Did you try concatenating the relative path into the url?
url = "https://*****/" & RelativePath
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi Pat, I got it to work. I'd tried putting it in as a parameter before but had neglected to change the parameter to a list type! So now when I put it in as a custom function within the column, I could then specify which column to use as the input and therefore which row. A bit of an epic journey.
@ImkeF I got it to work and learnt a lot 🙂
Hi @suebayes ,
not sure I can follow.
But I would recommend to test out the desired URL in the browser or a tool like Postman to check general correctness.
Then we could try to "translate" it to Power Query and troubleshoot if necessary.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.