Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 |
User | Count |
---|---|
8 | |
7 | |
4 | |
4 | |
4 |