# HTTP checks - Saving

**URL:** <https://community.gatling.io/t/http-checks-saving/6232>\
**Category:** Gatling (Open-Source)\
**Created:** [August 26, 2021, 2:50pm UTC](https://community.gatling.io/t/http-checks-saving/6232 "2021-08-26T14:50:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Polaske](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Thomas\_Polaske](https://community.gatling.io/u/Thomas_Polaske)\
**Post date:** [August 26, 2021, 2:50pm UTC](https://community.gatling.io/t/http-checks-saving/6232/1 "2021-08-26T14:50:32Z")

</div>

I am iterating over the same post statement and would like to save each response somehow in a list. Is this possible?

From the reference it only looks like you can save this as a string? And it looks like if I try to do this multiple times it does not save anything?  
[https://gatling.io/docs/gatling/reference/current/http/check/#saving](https://gatling.io/docs/gatling/reference/current/http/check/#saving)

Thanks!  
Tom

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [August 26, 2021, 2:58pm UTC](https://community.gatling.io/t/http-checks-saving/6232/2 "2021-08-26T14:58:42Z")

</div>

Hi!

> it looks like if I try to do this multiple times it does not save anything?

`saveAs` should save your last result.  
Are you sure that your last result is not empty?

> would like to save each response somehow in a list

My approach is:

- to create a session variable (`acc`) with an empty list
- save the current result in another variable (`tmp`)
- make a step to add the second variable to the first one

Something like:

```auto
  .exec(session => session.set("acc", session("acc").as[List[String]] :+ session("tmp").as[String])

```

(warning: not tested)

I hope that helps!

Cheers!

---

<div class="post-metadata">

**Author:** ![Thomas\_Polaske](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Thomas\_Polaske](https://community.gatling.io/u/Thomas_Polaske)\
**Post date:** [August 26, 2021, 5:25pm UTC](https://community.gatling.io/t/http-checks-saving/6232/3 "2021-08-26T17:25:16Z")

</div>

Hmm ya that doesn’t seem to be working. But I’m not sure I initiated the list correctly? Is this how you would to create a session variable ( resourceUidList ) with an empty list (couldn’t find anything in the doc about this)?

.exec(session =\> session.set(“resourceUidList”, {}))

If that is correct… it doesnt seem to work when I try to add to it like so

exec(session =\> session.set(“resourceUidList”, session(“resourceUidList”).as[List[String]] :+ session(“resourceUid”).as[String]))

the session var is empty

resourceUidList → ()

What I would like to do is take this list and iterate each value to a PUT request.

Another way I could do that is I add all the resourceIds to a local array variable (not is session)

Then I can iterate over using repeat

repeat(times, counterName) {

myChain

}

_according to the docs times_ can be an Int,

so my code looks like this

.repeat(numberOfRulesets, “counter”) {

TestUtil.putRuleset("${rulesetId}", rulesetFilePath, “${counter}”).pause(2) // This is my PUT request

}

However it does not seem like this counter is working? Not sure what I am doing wrong but it seems unable to get that value to index on my array.

please let me know if you see anything incorrect about either option thanks!?

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [August 26, 2021, 7:00pm UTC](https://community.gatling.io/t/http-checks-saving/6232/4 "2021-08-26T19:00:44Z")

</div>

Curly braces are only empty block in Scala.  
Try with Nil or List() to initialize it

---

<div class="post-metadata">

**Author:** ![Thomas\_Polaske](https://avatars.discourse-cdn.com/v4/letter/t/edb3f5/32.png) [@Thomas\_Polaske](https://community.gatling.io/u/Thomas_Polaske)\
**Post date:** [August 26, 2021, 7:33pm UTC](https://community.gatling.io/t/http-checks-saving/6232/5 "2021-08-26T19:33:30Z")

</div>

hmm not sure that is going to work :(. Not sure what I am missing this should be pretty simple… I posted another question as a workaround
