Forum Discussion
Ackbar-Learner
Resolver I
2 years agoQuery takes too much time to load in Power Pivot Data Model
Hi I am using Power Query and a software key to feed in an API, which then returns me a token and then using that token, I can access the databases as set in the software documentation. I have co...
lbendlin
Super User
2 years agoPlease follow the documentation: Web.Contents - PowerQuery M | Microsoft Learn
Ackbar-Learner
Resolver I
2 years agoIt used to take 15 mins. Now it is around 4 mins 😀. I am writing the code below just in case someone has another suggestion to bring down that 4 min.
let
// Step 1: Define the Software Key parameter
softwareKey = "zzzzz",
// Define the base URL
baseUrl = "http://xxxxx/api/v1/",
// Step 2: Define a function to obtain the token
GetToken = () =>
let
response = Web.Contents(baseUrl, [
RelativePath = "token/" & softwareKey
]),
tokenResponse = Json.Document(response),
token = tokenResponse[TokenGuid]
in
token,
// Step 3: Obtain the token
token = GetToken(),
// Step 4: Define a function for API requests with token
GetAPIData = (endpoint as text) =>
let
response = Web.Contents(baseUrl, [
RelativePath = endpoint,
Headers = [
header = token,
#"Content-Type"="application/json"
]
]),
data = Json.Document(response)
in
data
in
GetAPIData
Thanks again lbendlin