我使用这种方式,它可以工作。授权类型是基本的,并且用户名和密码已编码。
![enter image description here](https://istack.dev59.com/CKXfu.webp)
let
url = "http://localhost:8091/_p/query/query/service?",
body = "{
""statement"": ""SELECT ROUND((SUM(src.DUR) / COUNT(.)), 0) AS 'Mean Screen Time per day' FROM \r\n(SELECT
SUM(TONUMBER(source.DURATION)) AS DUR, source.startDate AS DATE FROM \r\n(SELECT startDate, DATE_DIFF_STR(completionDate,
startDate, 'second') AS DURATION, attributes.screen AS SCREEN \r\nFROM data WHERE type_ = \""Event\"" AND type is NOT MISSING and
startDate IS NOT MISSING and completionDate IS NOT MISSING \r\nand completionDate > startDate and attributes.screen IS NOT
MISSING) source GROUP BY source.startDate) src"",
""pretty"":true,""timeout"":""600s"",""profile"":""timings"",""scan_consistency":"not bounded"",""client_context_id"":""xyz""}",
Source = Json.Document(Web.Contents(
url,[
Timeout=#duration(0,0,120,0),
Headers=[#"Authorization"="Basic YXB",#"Content-Type"="application/json"],
Content=Text.ToBinary(body)
]
)
),
results = Source[results],
#"Converted to Table" = Table.FromList(results, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"MEAN _DURATION", "SCREEN"},{"MEAN DURATION","SCREEN"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Column1",{{"MEAN_DURATION", type number}})
in
#"Changed Type"