# Iteratively send list of bodies to endpoint

**URL:** <https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994>\
**Category:** Gatling (Open-Source)\
**Tags:** gatling-academy\
**Created:** [June 5, 2023, 12:54pm UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994 "2023-06-05T12:54:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 5, 2023, 12:54pm UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/1 "2023-06-05T12:54:36Z")

</div>

My desired scenario is as follows: I have a list of URLs. I would like to obtain load testing results for GET requests to every single URL separately. In other words, I want it to perform `N` (say 100) requests per URL and show the results separately in the Gatling dashboard.

Currently, the code looks like this

```java
private final ScenarioBuilder scenario =
    scenario("Requests")
      .exec(
        http("Single request")
          .get(<URL from list of URLs>));

```

I then set up and activate the scenario like this

```auto
    setUp(scenario.injectOpen(
      constantUsersPerSec(5)
        .during(Duration.ofSeconds(5))))
      .protocols(httpProtocol);

```

And for any future Gatling beginners, I use the following protocol setup

```java
private final HttpProtocolBuilder httpProtocol =
  http.userAgentHeader("Gatling response profiling");

```

How do I adapt my code such that a load test is executed for every URL in the list?

---

<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:** [June 5, 2023, 1:17pm UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/2 "2023-06-05T13:17:09Z")

</div>

Hi @GIGATeun,

Did you consider using [Feeders](https://gatling.io/docs/gatling/reference/current/core/session/feeder/)?

Cheers!

---

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 5, 2023, 2:27pm UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/3 "2023-06-05T14:27:29Z")

</div>

@sbrevet yes. Let’s give a full working example. Suppose we use

```java
  FeederBuilder feeder = listFeeder(Arrays.asList(
    Collections.singletonMap("url", <URL 1>),
    Collections.singletonMap("url", <URL 2>)
  )).random();

```

and adapt our code as follows

```java
private final ScenarioBuilder scenario =
    scenario("Requests")
      .feed(feeder)
      .exec(
        http("Single request")
          .get("#{url}"));

```

Then the Gatling dashboard will aggregate all of the requests under the same name under the “Details” view. What I want is for Gatling to split them up, and analyze them separately as if they were different load tests. I don’t want to manually change the parameters and rerun Gatling.

---

<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:** [June 5, 2023, 3:19pm UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/4 "2023-06-05T15:19:43Z")

</div>

> [@GIGATeun](#):
>
> Then the Gatling dashboard will aggregate all of the requests under the same name under the “Details” view.

Under which does Gatling aggregate? I guess under `"Single request"`.  
You may try to put it in your request name. Beware that the amount of different names is limited for performance reason.

```java
private final ScenarioBuilder scenario =
    scenario("Requests")
      .feed(feeder)
      .exec(
        http("#{url}")
          .get("#{url}"));

```

Cheers!

---

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 9, 2023, 11:20am UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/5 "2023-06-09T11:20:14Z")

</div>

Yes, the Gatling dashboard appears to aggregate under `"Single request"`. Your example provides a great solution. I was unaware you could use feeders this flexibly. Thanks!

---

<div class="post-metadata">

**Author:** ![GIGATeun](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@GIGATeun](https://community.gatling.io/u/GIGATeun)\
**Post date:** [June 9, 2023, 11:22am UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/6 "2023-06-09T11:22:22Z")

</div>

Also the topic title is incorrect I see now. Initially I wanted to send different bodies to one endpoint, but I decided to provide another use case halfway through. The core of the question remains the same though.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [July 9, 2023, 11:22am UTC](https://community.gatling.io/t/iteratively-send-list-of-bodies-to-endpoint/7994/7 "2023-07-09T11:22:24Z")

</div>

Closed on July 9, 2023, 11:22am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
