Forum Discussion
Published Report refuses to refresh when using API as source and bearer token
- Anonymous2 years ago
Hi Everyone!
OK I found a workaround. I will describe the problem and why it happens, and what I did1) Incremental refresh will try and pull data for every day you want archived and refreshed 1 day at a time. So it will pass those dates into your API call
2) If you have no data on those days, the "rows" JSON will be empty
2) In my query, it expects the "rows" JSON to have data to construct the table. So we have to handle situations where it returns no data
What I did, is i added a "try" and "otherwise" to that line that tries to expand the record from the empty table i created from the "rows" JSON, and inside the otherwise, just pointed it to the "columns" JSON which will always be populated (just 1 row of the column headers)
Before Table.ExpandRecordColumn(#"Converted to Table2", "Column1", {"values"}, {"Call"})After try Table.ExpandRecordColumn(#"Converted to Table2", "Column1", {"values"}, {"Call"}) otherwise Table.ExpandRecordColumn(Table.FromList(columns1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Now, this only worked for MY particular use case because of how i build out the tables from the JSON, but the main point remains when dealing with APIs and scheduled refresh: You have to handle days where there is no data. Your query has to output the same format of data regardless of if there is data or not.
Doing the above fixed my issue. I hope this helps someone who comes across this again
Hi Everyone!
OK I found a workaround. I will describe the problem and why it happens, and what I did
1) Incremental refresh will try and pull data for every day you want archived and refreshed 1 day at a time. So it will pass those dates into your API call
2) If you have no data on those days, the "rows" JSON will be empty
2) In my query, it expects the "rows" JSON to have data to construct the table. So we have to handle situations where it returns no data
What I did, is i added a "try" and "otherwise" to that line that tries to expand the record from the empty table i created from the "rows" JSON, and inside the otherwise, just pointed it to the "columns" JSON which will always be populated (just 1 row of the column headers)
Before Table.ExpandRecordColumn(#"Converted to Table2", "Column1", {"values"}, {"Call"})
After try Table.ExpandRecordColumn(#"Converted to Table2", "Column1", {"values"}, {"Call"}) otherwise Table.ExpandRecordColumn(Table.FromList(columns1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Now, this only worked for MY particular use case because of how i build out the tables from the JSON, but the main point remains when dealing with APIs and scheduled refresh: You have to handle days where there is no data. Your query has to output the same format of data regardless of if there is data or not.
Doing the above fixed my issue. I hope this helps someone who comes across this again