我的回应是:
[
{"id":106455,"assetId":482282,"masterKeyframeId":157060,"closed":false},
{"id":106661,"assetId":502174,"masterKeyframeId":169193,"closed":false}
{.....and so many...}
]
我已经使用下面的请求正确获取了“assetId”和“masterKeyframeId”,但问题是如何在foreach循环中设置这两个值? (我使用了“aid”并且它获取单个值,但不知道为“mkeyframeId”传递单个值,因为它需要Vector)
.exec(http("request_7")
.get(uri3 + "/sortBy=SEGGREGATED_SESSION_SORT;reviewState=IN_PROGRESS")
.check(jsonPath("$..assetId").findAll.saveAs("astId"))
.check(jsonPath("$..masterKeyframeId").findAll.saveAs("mkeyframeId"))
.headers(headers_7)
)
.foreach("${astId}", "aid") {
doIf(session => session("aid").as[String] != "-1")
{
exec(http("Set_IDs")
.get("/a/" + accountname + "/assets/${aid}/keyframe/${mkeyframeId}")
)
}
}
这里的问题是${mkeyframeId}
它需要向量并传入这样的url,
发送请求= Set_IDs uri = https://qa1.net/a/hbmin1ac/assets/482282/keyframe/Vector(157060,%20169193):
而不是
https://qa1.net/a/hbmin1ac/assets/482282/keyframe/157060
https://qa1.net/a/hbmin1ac/assets/502174/keyframe/169193
感谢。
答案 0 :(得分:1)
你应该尝试这样的事情:
.foreach("${astId}", "aid", "counter") {
doIf { session =>
for {
aid <- session("aid").validate[String]
} yield aid != "-1"
} {
exec(http("Set_IDs")
.get { session =>
for {
aid <- session("aid").validate[String]
mkeyframeId <- session("mkeyframeId").validate[Seq[String]]
c <- session("counter").validate[Int]
} yield s"/a/$accountname/assets/$aid/keyframe/${mkeyframeId(c)}"
}
)
}
}
您也可以像这样编写doIf块:
doIf( _("aid").validate[String].map(_ != "-1"))