【发布时间】:2023-04-03 12:41:01
【问题描述】:
我有一个生成 JSON 的 Web 服务。我们对其进行 jQuery REST 调用并将数据绑定到表。
服务是 C# WEBAPI,代码如下:
data = serializer.Serialize(rows);
return Request.CreateResponse(HttpStatusCode.OK, lstFilteredData, Configuration.Formatters.JsonFormatter);
它会生成这样的 JSON:
"[{\"School\":\"UM \",\"Students\":\"500\"},{\"School\":\"FIU \",\"Students\":\"700\"},{\"School\":\"UF \",\"Students\":\"600\"},{\"School\":\"GT \",\"Students\":\"300\"}]"
我们有 jQuery REST 可以像这样成功使用服务:
$.ajax({
url: 'https://myservices')),
type: 'GET',
dataType: 'json',
cache: false,
crossDomain: true,
//async: false,
success: function (data){ onQuerySucceededWeb(data,true,param);}
});
我正在尝试使用 Power Bi 报告该数据。我的 PowerBi 查询脚本是: 让
Source = Json.Document(Web.Contents("https://mywebservices")),
#"Converted to Table" = Record.ToTable(Source),
#"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"),
#"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"School", "Students"}, {"Value.School", "Value.Students"})
in
#"Expanded Value1"
我收到此错误:
**Expression.Error: We cannot convert the value "[{"School":"UM ..." to type Record.**
Details:
Value=[{"School":"UM ","Students":"500"},{"School":"FIU ","Students":"700"},{"School":"UF ","Students":"600"},{"School":"GT ","Students":"300"}]
Type=Type
【问题讨论】:
-
如果你使用 = Text.FromBinary(Web.Contents("mywebservices")) 会出现什么?
-
我应该把它放在哪里?代替我的整个查询脚本?
-
相同。 Expression.Error:我们无法将值“”[{\“School\”:\“UM ...”转换为类型记录。
-
如果将
Record.ToTable(Source)替换为Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),然后将后面两步替换为Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"School", "Students"}, {"School", "Students"})会怎样 -
Expression.Error: 我们无法将值 ""[{\"School\":\"UM ..." 转换为类型列表。详情:
标签: json rest powerbi powerquery