[英]How to pass response body field to other request's body (Gatling)
我有兩個終點。
-/認證
-/驗證/驗證
/ authenticate響應正文上的return guid字段。 和/ authenticate / verification需要請求正文中的該字段。
我試圖得到這樣的guid:
jsonPath("$..guid").saveAs("verificationGuid")
並傳遞給其他身體:
.body(StringBody(s"{\\"guid\\":${verificationGuid}, \\"code\\":\\"123456\\"}"))
這是代碼塊:
def login = {
exec(http("Authenticate")
.post("/authenticate")
.body(StringBody(userString))
.headers(headerLogin)
.check(status is 200)
.check(jsonPath("$..guid").saveAs("verificationGuid"))
)
.exec(http( "Authenticate verify")
.post("/authenticate/verify")
.headers(headerLogin)
.body(StringBody(s"{\"guid\":${verificationGuid}, \"code\":\"123456\"}"))
.check(status is 200)
)
}
但是它不起作用,我該怎么辦?
刪除s
從s"{\\"guid\\":${verificationGuid}, \\"code\\":\\"123456\\"}")
如果s
在字符串前面,則每個${something}
占位符將被視為Scala內置於字符串插值中,並且編譯器將嘗試用Scala變量替換它,在您的情況下該變量不存在。 如果不使用s
,它將被視為原義字符串,而不是被Gatling EL Parser捕獲,並被先前保存的Gatling會話屬性取代。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.