This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I have a report that works fine in Power BI desktop (retrieving JSON data from a public web API using Json.Document(Web.Contents()) ). However, when I publish I get the error that "Your data source can't be refreshed because the credentials are invalid". Full query below. URLs changed for privacy:
let
AuthKey = GetSessionId(),
url = "https://publicapi.com",
body = "{typeName: 'Project',
fields: ['name', 'TrackStatus.name', 'BudgetStatus.name'],
where: {
_type: 'Compare',
leftExpression: {fieldName: 'State'},
operator: 'Equal',
rightExpression: {value: 'Active'}
},
}",
Source = Json.Document(Web.Contents(url,[
Headers = [#"Authorization"= AuthKey ,
#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
)),
entities = Source[entities],
in
entitiesThe GetSessionId() method refers to another query to another web api to receive the session id
let
Source = Json.Document(Web.Contents("https://publicapi.com",[
Headers = [#"Content-Type"="application/json"],
Content = Text.ToBinary("{userName:'<user>',password:'<pass>'}")
]
)),
sessionId = "Session " & Source[sessionId]
in
sessionId
Hi @evidence,
Currently, power query custom function only available on desktop side. Perhaps you can merge your functions to one query and try again.
Regards,
Xiaoxin Sheng
Hi,
Thanks for your answer. Any idea how I would merge the two queries?
I tried the following, but had the same error on the server.
let
login = Json.Document(Web.Contents("https://api.com/login",[Headers = [#"Content-Type"="application/json"],Content = Text.ToBinary("{userName:'<user>',password:'<pass>'}")])),
AuthKey = "Session " & login[sessionId],
url = "https://api.com/EntityQuery",
body = "{typeName: 'Project',
fields: ['name', 'TrackStatus.name', 'BudgetStatus.name'],
where: {
_type: 'Compare',
leftExpression: {fieldName: 'State'},
operator: 'Equal',
rightExpression: {value: 'Active'}
},
}",
Source = Json.Document(Web.Contents(url,[
Headers = [#"Authorization"= AuthKey ,
#"Content-Type"="application/json"],
Content = Text.ToBinary(body)
]
)),
entities = Source[entities],
#"Converted to Table" = Table.FromList(entities, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "name", "TrackStatus", "BudgetStatus"}, {"Column1.id", "Column1.name", "Column1.TrackStatus", "Column1.BudgetStatus"}),
#"Expanded Column1.TrackStatus" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.TrackStatus", {"name"}, {"Column1.TrackStatus.name"}),
#"Expanded Column1.BudgetStatus" = Table.ExpandRecordColumn(#"Expanded Column1.TrackStatus", "Column1.BudgetStatus", {"name"}, {"Column1.BudgetStatus.name"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Column1.BudgetStatus",{{"Column1.BudgetStatus.name", "Budget Status"}, {"Column1.name", "Project Name"}, {"Column1.TrackStatus.name", "Schedule Status"}, {"Column1.id", "Project Id"}})
in
#"Renamed Columns"
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 13 | |
| 11 | |
| 8 | |
| 8 | |
| 7 |
| User | Count |
|---|---|
| 38 | |
| 27 | |
| 25 | |
| 22 | |
| 22 |