Forum Discussion
Help with dynamic data source refresh and RelativePath+Web.Contents
- 3 years ago
Hi dor-rog-tech
Set the options for the data source to skip the connection test and try that again?
Hi GilbertQ
I tried using RelataivePath as an Option and followed the instructions in the articles you sent but there is still an issue and this time it is another one:
Here is a current query:
let
apiUrl = "https://api.tadabase.io/api/v1",
relativePath = "/data-tables/<REPLACE-WITH-YOUR-TABLE-ID>/records",
perPage = 100,
GetJson = (Page) =>
let Options = [
Headers=[
#"X-Tadabase-App-Key"="<REPLACE WITH YOUR APP KEY>",
#"X-Tadabase-App-Secret"= "<REPLACE WITH YOUR APP SECRET>",
#"X-Tadabase-App-id"="<REPLACE WITH YOUR APP ID>"
],
RelativePath=relativePath,
Query=[
page=Page,
limit=Text.From(perPage)
]
],
RawData = Web.Contents(apiUrl, Options),
Json = Json.Document(RawData)
in Json,
GetPage = (Index) =>
let Page = Text.From(Index),
Json = GetJson(Page),
Value = Json
in Value,
getRecords = (page as number, AccumData as list) =>
let
Data = Function.InvokeAfter(()=>GetPage(page), #duration(0,0,0,2)),
Result =
if page >= Data[total_pages]
then Table.FromRecords(List.Combine({AccumData, Data[items]}))
else @getRecords(page + 1, List.Combine({AccumData, Data[items]}))
in
Result,
Records = getRecords(1, {})
in
#"Renamed Columns"As I understand PowerBi firstly will check the baseUrl and only then do a call. But in our case, an api requires custom headers (all 'X-Tadabase..." headers) even for the base URL
Am I right?
If so is there any way to provide these headers from outside a query?
Thank you
Hi dor-rog-tech
Set the options for the data source to skip the connection test and try that again?
- dor-rog-tech3 years ago
Helper I
Thanks GilbertQ !
- jp1233 years agoFrequent Visitor
Hi dor-rog-tech,
Were you able to get the relative path and scehduled refresh to work on your Tadabase data source?
I cannot get it to work with my code. Can you please help and show me where I should place the RelativePath code? Here is my query... Any assisteance would be greatly appreciated!
let apiUrl = "https://api.tadabase.io/api/v1/data-tables/xxxxx", perPage = 100, GetJson = (Url) => let Options = [Headers =[ #"X-Tadabase-App-Key"= "xxxx", #"X-Tadabase-App-Secret"= "xxxx", #"X-Tadabase-App-id"="xxxx" ] ], RawData = Web.Contents(Url, Options), Json = Json.Document(RawData) in Json, GetPage = (Index) => let Page = "page=" & Text.From(Index), Limit = "limit=" & Text.From(perPage), Url = apiUrl & "?" & Page & "&" & Limit, Json = GetJson(Url), Value = Json in Value, getRecords = (page as number, AccumData as list) => let Data = Function.InvokeAfter(()=>GetPage(page), #duration(0,0,0,2)), Result = if page >= Data[total_pages] then Table.FromRecords(List.Combine({AccumData, Data[items]})) else @getRecords(page + 1, List.Combine({AccumData, Data[items]})) in Result,