Power App-来自Flow的响应不会被视为json

时间:2019-07-08 13:12:01

标签: json powerapps microsoft-flow

我有一个强大的应用程序,希望从其余API收集一些数据,我正在使用Flow,因为这似乎是推荐的方法。

我有一个收藏集:

[
    {id: 1,name: "test",lines: [
            {id: 244,
                StrategyId: 1,
                TypeId: 0,
                Weight: 10,
                toWeight: 200
            }
        ]
    },
    {id: 3,name: "test2",lines: [
            {id: 262,
                StrategyId: 3,
                TypeId: 0,
                Weight: 0,
                toWeight: 200
            }
        ]
    }
]

当我直接将其输入公式时,效果很好:

ClearCollect( CityPopulations, json...)

但是,当我尝试从Flow获取数据时,它只会返回一个包含一个条目的集合,该条目是json数据作为字符串。

 Set('CityPopulations','PowerApp->Sendmeamobilenotification'.Run());ClearCollect(NewTable, CityPopulations.testoutput);

在Microsoft流程中,我使用PowerApps触发器并响应PowerApps。

还请注意,json结构中的属性名上没有“”,但这是我可以让Power Apps实际接受手动键入json的唯一方法。我已经尝试了使响应正确,以及这种方式。我必须调整流程以删除属性名称周围的“。结果还是一样。

这是表在集合中的外观: enter image description here

这是我手动输入数据时的外观:

enter image description here

这是来自的直接输出:

{
  "testoutput": "[{id:1,name:\"test\",lines:[{id:244,StrategyId:1,TypeId:0,fromWeight:10,toWeight:200}]},{id:2,name:\"tester\",lines:[{id:154,StrategyId:2,TypeId:0,fromWeight:10,toWeight:200}]}]"
}

最大的区别是从流中添加了转义字符。

enter image description here

2 个答案:

答案 0 :(得分:1)

这花了我很多时间来解决,因此也许会对其他人有所帮助。

当您要将流(数组)形式的Flow返回到Canvas应用时,您需要使用响应(请求),而不是响应PowerApp。

所有问题都随之消失

提示:记住要提供SCHEMA并在画布应用程序中删除并重新添加流

答案 1 :(得分:0)

看起来您是从API响应中收集文本的单个列,而不是收集整个响应。

尝试仅使用: ClearCollect(colNewTable,'PowerApp->Sendmeamobilenotification'.Run())

如果要将colNewTable设置为变量,则将其包装为:

Set(varNewTable,ClearCollect(colNewTable,'PowerApp->Sendmeamobilenotification'.Run())

希望这会有所帮助!