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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello all, I'm trying to extract some values from a local json file:
confPath = "C:\<path>",
configFile = File.Contents(confPath, BinaryEncoding.Base64) as binary,
configText = Binary.ToText(configFile, BinaryEncoding.Base64),
configJson = Json.Document(configText),
AuthUrl = Record.Field(configJson, "url") & "auth?",
the json is :
{
"other_field": "other_field",
"url": "http://localhost:1852/realms/local-development/protocol/openid-connect/"
}
from the powerBI I have a runtime error: [Expression.Error] "We cannot convert the value 0 to type Record". What is wrong here?
Solved! Go to Solution.
@Ferna Maybe this?
let
Source = Json.Document(File.Contents("C:\temp\testjson.json")),
#"Converted to Table" = Table.FromRecords({Source}),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"other_field", type text}, {"url", type text}})
in
#"Changed Type"
@Ferna Maybe this?
let
Source = Json.Document(File.Contents("C:\temp\testjson.json")),
#"Converted to Table" = Table.FromRecords({Source}),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"other_field", type text}, {"url", type text}})
in
#"Changed Type"
It doesn't work, with same error. Also, if you not specify the encoding type, it does not compile: "UnpermittedResourceAccessException". I try also:
File.Contents(confPath, BinaryEncoding.Hex)
but similar error "We cannot convert the value 1 to type Record"
@Ferna It works fine for me. I just took your json and pasted into Notepad and saved as testjson.json. I'm not understanding the binary encoding stuff you are doing. Is your json file not text? I would think it would be text.
File.Contents(<path>)is not available when you are customizing a data connector (so not authorized to use). I accept as a solution because works in normal conditions.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 8 | |
| 4 | |
| 3 | |
| 3 |