# Having Problems with saveAs

**URL:** <https://community.gatling.io/t/having-problems-with-saveas/4535>\
**Category:** Gatling (Open-Source)\
**Created:** [September 27, 2018, 11:10am UTC](https://community.gatling.io/t/having-problems-with-saveas/4535 "2018-09-27T11:10:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfgang\_Klein](https://avatars.discourse-cdn.com/v4/letter/w/f19dbf/32.png) [@Wolfgang\_Klein](https://community.gatling.io/u/Wolfgang_Klein)\
**Post date:** [September 27, 2018, 11:10am UTC](https://community.gatling.io/t/having-problems-with-saveas/4535/1 "2018-09-27T11:10:53Z")

</div>

Hi everyone, im new to Gatling and can’t figure out how to get “saveAs” to work the way i want.  
I’m trying to save variables form one response and use them in the next request.

`  
import scala.concurrent.duration.\_

import io.gatling.core.Predef.\_  
import io.gatling.http.Predef.\_  
import io.gatling.jdbc.Predef.\_

class demo extends Simulation {

var idToken = “”  
var clientID = “”

val httpProtocol = http  
.baseURL(“[https://placeholder.com](https://placeholder.com)”)  
.proxy(Proxy(“[proxy.placeholder.com](http://proxy.placeholder.com)”, 88).httpsPort(88))  
.inferHtmlResources()  
.userAgentHeader(“Java/1.8.0\_73”)

val headers\_GetAccessToken\_App\_0 = Map(  
“Accept” → “application/json”,  
“Accept-Encoding” → “gzip,deflate”,  
“Content-Type” → “application/json”  
)

val headers\_GetAccessToken\_App\_1 = Map(  
“Accept” → “application/json”,  
“Accept-Encoding” → “gzip,deflate”,  
“Content-Type” → “application/json”  
)

val headers\_GetAccessToken\_App\_2 = Map(  
“Accept-Charset” → “UTF-8”,  
“Accept” → “application/json”,  
“Accept-Encoding” → “gzip,deflate”,  
“Content-Type” → “application/json”  
)

val GetAccessToken\_App\_0 = scenario(“GetAccessToken\_App\_0”)  
.exec(http(“request\_GetAccessToken\_App\_0”)  
.post(“[https://placeholder.com/password=placeholder](https://placeholder.com/password=placeholder)”)  
.headers(headers\_GetAccessToken\_App\_0)  
.check(jsonPath("$.id\_token").find.saveAs(idToken)))  
.pause(1)  
.exec(http(“request\_GetAccessToken\_App\_1”)  
.post(“[https://placeholder.com/mobile/register](https://placeholder.com/mobile/register)”)  
.headers(headers\_GetAccessToken\_App\_1)  
.body(RawFileBody(“Payload\_GetAccessToken\_App\_1.txt”))  
.check(jsonPath("$.client\_id").find.saveAs(clientID)))  
.pause(5)  
.exec(http(“request\_GetAccessToken\_App\_2”)  
.post(“[https://placeholder.com/token="+"${idToken}](https://placeholder.com/token=%22+%22%24%7BidToken%7D)”)  
.headers(headers\_GetAccessToken\_App\_2)  
.header(“x-client-id”, “${clientID}”)  
)

setUp(GetAccessToken\_App\_0.inject(atOnceUsers(1))).protocols(httpProtocol)  
}  
`

I get: “Failed to build request request\_GetAccessToken\_App\_2: No Attribute named ‘idToken’ is defined” as an error when I run the simulation and can’t seem to find out how to fix it.

Thanks in advance,  
Wolfgang

PS: ignore the URLs, they have been changed to omit sensitive information

---

<div class="post-metadata">

**Author:** ![Julia](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Julia](https://community.gatling.io/u/Julia)\
**Post date:** [September 27, 2018, 4:20pm UTC](https://community.gatling.io/t/having-problems-with-saveas/4535/2 "2018-09-27T16:20:33Z")

</div>

Hi Wolfgang,  
You need to use quotes around the attribute name (saveAs param):

`.check(jsonPath("$.id_token").find.saveAs("idToken")))`

And no need to have a variable for that.

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Klein](https://avatars.discourse-cdn.com/v4/letter/w/f19dbf/32.png) [@Wolfgang\_Klein](https://community.gatling.io/u/Wolfgang_Klein)\
**Post date:** [September 28, 2018, 6:59am UTC](https://community.gatling.io/t/having-problems-with-saveas/4535/3 "2018-09-28T06:59:54Z")

</div>

Hi Julia,

thanks for the quick answer. It seems to work, though I can’t really say since the servers I’m testing on are down atm. ☹

thanks a lot,  
Wolfgang

PS: for being such an easy fix I wasted way too much time on this 🙂
