How to get variables from http response?

How to simulation this curl request:

`

curl -vF ‘code=mycode’ http://localhost:7001/login

  • Trying 127.0.0.1…
  • Connected to localhost (127.0.0.1) port 7001 (#0)

POST /login HTTP/1.1
Host: localhost:7001
User-Agent: curl/7.47.0
Accept: /
Content-Length: 145
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------e292977ce5768cb5

  • Done waiting for 100-continue
    < HTTP/1.1 200 OK
    < content-type: text/json; charset=utf-8
    < Content-Length: 210
    <
  • Connection #0 to host localhost left intact
    {“token”:“eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuaWNrbmFtZSI6ImxvcmlzcHkiLCJpZCI6MSwiZXhwIjoxNDg4ODExNzg3LCJpYXQiOjE0ODM2Mjc3ODcsIm9wZW5JZCI6IjEzNTcyMjA5MTgzIn0=.3Zu7ZM9NW5BMeIFBs7JwpHMBpeDA7TRTz5Y-_mhAf7E=”}

curl -v -H ‘Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuaWNrbmFtZSI6ImxvcmlzcHkiLCJpZCI6MSwiZXhwIjoxNDg4ODExNzg3LCJpYXQiOjE0ODM2Mjc3ODcsIm9wZW5JZCI6IjEzNTcyMjA5MTgzIn0=.3Zu7ZM9NW5BMeIFBs7JwpHMBpeDA7TRTz5Y-_mhAf7E=’ http://127.0.0.1:7001/home

`

I want to get “token” from response from “http://127.0.0.1:7001/login”, then add to header to request “http://127.0.0.1:7001/home

`

val scn = scenario(“s1”)
.exec(http(“login”)
.post("/login")
.formParam(“code”, “mycode”)
.headers(Map(“Content-Type” → “multipart/form-data”))
.check(status.is(200)

`

And next?

Thanks.

.check(jsonPath("$.token").find.saveAs(“token”)

and

.headers(Map(“token” → “${token}”)

Should work I guess,

  1. január 5., csütörtök 16:41:36 UTC+1 időpontban Feng Yu a következőt írta:

It works, thanks.

在 2017年1月6日星期五 UTC+8上午2:44:15,Viktor Farkas写道: