Forum Discussion
Ackbar-Learner
2 years agoResolver I
Query 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...
Ackbar-Learner
2 years agoResolver I
I can re-use the same tokens. I have not done the relative path before. Can you help?
lbendlin
2 years agoSuper User
Please follow the documentation: Web.Contents - PowerQuery M | Microsoft Learn
- Ackbar-Learner2 years agoResolver I
It 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 GetAPIDataThanks again lbendlin