我有一个matches
保存到 var 的集合。每个match
都有一个gameId
。我想用它gameId
来进行 API 调用。我使用var
为每个范围设置了一个。matches
counter
<set-variable value="#[payload]" doc:name="Set Matches" doc:id="bb1093b0-3dd9-4515-8f42-dd496f00477b" variableName="matches"/>
<set-variable value="#[[]]" doc:name="Deaths" doc:id="a7341e19-07f8-418d-b39a-5bc415e75fba" variableName="deaths"/>
<foreach doc:name="For each match" doc:id="506fa944-d46f-4684-9c75-73088265ca80" collection="vars.matches" rootMessageVariableName="matches">
<http:request method="GET" doc:name="GetTimeline" doc:id="63708489-4d10-4e79-b5aa-c8fc723e80c6" config-ref="HTTP_Request_configuration" path="/match/v4/timelines/by-match/{matchId}">
<http:uri-params ><![CDATA[#[output application/java
---
{
"matchId" : vars.matches[vars.counter + 1].gameId
}]]]></http:uri-params>
</http:request>
<ee:transform doc:name="MapDeaths" doc:id="a6e22968-2229-4574-8cae-44225013b9cf">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
{
frames: payload.frames map ( frame , indexOfFrame ) -> {
events: frame.events map ( event , indexOfEvent ) -> vars.deaths + event
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</foreach>
然而matchId
从"matchId" : vars.matches[vars.counter + 1].gameId
总是评估为空。我在那里想念什么?
编辑:
我正在使用 Mule 4.2,匹配的 json 结构如下所示:
[
{
"matches": [
{
"key": "val",
"key": val,
...
},
{
"key": "val",
"key": val,
...
},
...