Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello Pals,
I am struggling to run the M code in Power BI service to refresh the data while it works fine in desktop. After i publish to service, the dataset renders an error: “Query contains unsupported function. Function name: Web.Contents”.
Can you please assist fix this issue by providing the right code to use ? We are using below reference api documentaion from the vendor provider.
https://docs.learninglocker.net/http-xapi-statements/#get-statements
Original M Script: (working in desktop but fails in Service)
let
url = “https://MainUrlHere.com”,
part = “/data/xAPI/statements”,
FnGetOnePage =
(url) as record =>
let
Source = Json.Document(Web.Contents(url, [Headers=[Authorization=”Basic token comes here”, #”X-Experience-API-Version”=”1.0.3″]])),
data = try Source[statements] otherwise null,
next = try Source[more] otherwise null,
Statements = [Data=data, Next=next]
in
Statements,
GeneratedList =
List.Generate(
()=>[i=0, Statements = FnGetOnePage(url & part)],
each [Statements][Data]null,
each [i=[i]+1, Statements = FnGetOnePage(url & [Statements][Next])],
each [Statements][Data]),
#”Converted to Table” = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#”Expanded Column1″ = Table.ExpandListColumn(#”Converted to Table”, “Column1″),
#”Expanded Column2″ = Table.ExpandRecordColumn(#”Expanded Column1”, “Column1”, {“id”, “actor”, “verb”, “context”, “timestamp”, “object”, “stored”, “authority”, “version”}, {“id”, “actor”, “verb”, “context”, “timestamp”, “object”, “stored”, “authority”, “version”})
in
#”Expanded Column2″
The API sends the data paginated, 100 elements (statements) by page. You can get all the data calling the API with the value of
“more” in each call.
PostMan output returned by the API:
“more”: “/data/xAPI/statements/?cursor=5ec825174a6905632eec1a8f”,
“statements”: [
{
“id”: “ddb382ab-fff6-4fac-9ffe-ea000722ac5e”,
“actor”: {
“objectType”: “Agent”,
“name”: “123456789”,
“mbox”: “mailto:abc@uat.com”
},
“verb”: {
“id”: “http://id.tincanapi.com/verb/viewed”,
“display”: {
“en-US”: “viewed”
}
},
“stored”: “2020-05-25T05:09:42.745Z”,
“authority”: {
“objectType”: “Agent”,
“name”: “beauat”,
“mbox”: “mailto:abc@uat.com”
},…….
“statements” is the list of elements to transform to Table in PowerBI. “more” is the relative path to add to the endpoint to call for the next page.
Modified M Script:
Per suggestion from other forums, i have added relative path but the script keeps running indefinite times in Desktop and does not stop. May be i am missing unknown. For testing purpose, i passed iterations as 5 and used in first each statement in List.Generate, it stop execution but same set of data is repeated, however i can publish to service and refresh without any errors.
let
url = "https://lrs-qa.brandexcellenceacademy.com",
part = "/data/xAPI/statements",
FnGetOnePage =
(url) as record =>
let
Source = Json.Document(Web.Contents("https://lrs-qa.brandexcellenceacademy.com",
[
RelativePath="/data/xAPI/statements",
Headers=[Authorization="Basic ZWMyNWNmMWZjMTcxODE4MDE0OTcxOTJlNmNjMmM4YzBmYzM1MzJhNDpiNGU1ZjkwYWU1YmI0M2FkMDlmNjBhYjg1ZjIxMTdkZDVjNmE0Zjc5", #"X-Experience-API-Version"="1.0.3"]
]
)),
data = try Source[statements] otherwise null,
next = try Source[more] otherwise null,
Statements = [Data=data, Next=next]
in
Statements,
GeneratedList =
List.Generate(
()=>[i=0, Statements = FnGetOnePage(url & part)],
each [Statements][Data]<>null,
each [i=[i]+1, Statements = FnGetOnePage(url & [Statements][Next])],
each [Statements][Data]),
#"Converted to Table" = Table.FromList(GeneratedList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandListColumn(#"Converted to Table", "Column1"),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1", {"id", "actor", "verb", "context", "timestamp", "object", "stored", "authority", "version"}, {"id", "actor", "verb", "context", "timestamp", "object", "stored", "authority", "version"})
in
#"Expanded Column2"
I would really appreciate any assistance from this community.
Thanks in advance,
Apoorva.
Hi @ApoorvaReddy ,
Since you could refresh it, you could use Query in Web.Contents to add some constraints so that prevent endless refresh.
Here is a document for your reference.
And you said that there will be duplicate data after refreshing? You could use Table.Distinct() fcuntion to remove duplicate data.
Hi,
I could not use any constraints in the web.contents as we need to pull all the data, however i tried to use data parameter to reduce the incoming data, the loop keeps running as never stops.
Duplicates can be restricted in visualizations, which is not a problem here. We somehow needs to end the for loop and i am not sure where the culprit is. The difference between original (refresh works fine in desktop) and modified script is (refresh works fine in Service but endless loop), i just added relative path to the modified script and everything else is same.
I am using below URL to come up with cursor based pagination as there is no paged-based pagination available from API call.
https://datachant.com/2016/06/27/cursor-based-pagination-power-query/#comment-22206
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 6 | |
| 5 | |
| 3 |