# Can't update body variable of request in for loop

**URL:** <https://community.postman.com/t/cant-update-body-variable-of-request-in-for-loop/56585>\
**Category:** Help Hub\
**Tags:** loops, postman-flows\
**Created:** [January 15, 2024, 10:52am UTC](https://community.postman.com/t/cant-update-body-variable-of-request-in-for-loop/56585 "2024-01-15T10:52:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nibhvdigitalimpact](https://avatars.discourse-cdn.com/v4/letter/n/7ea924/32.png) [@nibhvdigitalimpact](https://community.postman.com/u/nibhvdigitalimpact)\
**Post date:** [January 15, 2024, 10:52am UTC](https://community.postman.com/t/cant-update-body-variable-of-request-in-for-loop/56585/1 "2024-01-15T10:52:34Z")

</div>

**Problem**  
I’ve several requests which collect information or send information. I include this flow with 2 loops. 1 of them is with a “Repeater” and the other, directly from a “For” loop.

Once I run the “For” loop with the request, it’s turning into an endless loop once I connected a variable or for loop body.

I think because the “Fail” return of the requests isn’t handled correctly, I tried to collect the “Fail” response, but that didn’t solve the issue.

The problem I think is, I can’t connect a variable to a body variable of a request, it doesn’t failed when it’s a uri variable.

**Tried**  
I already implemented a way of mapping the course id with the student, but because the student uuid is based inside the body of the request it doesn’t work, once I removed the variable out of the body it works, but I need the uuid.

 ![Scherm­afbeelding 2024-01-15 om 12.45.40](https://us1.discourse-cdn.com/getpostman/original/3X/8/0/805ab87e6b96b64dfa98b2de3c8a03d023a08e18.png)

**Acceptance**  
I want to fix this “For” loop and understand what I did wrong…

**Path**

1. Creating and collecting students.
2. Assign students with a “For” loop on a course.

**Flow overview**  
You can find the loop at 7th purple block.

 ![Scherm­afbeelding 2024-01-15 om 11.51.09](https://us1.discourse-cdn.com/getpostman/original/3X/4/7/473c97ef2a5d6dfda0602b528dbab70406d54fb7.jpeg)

**Legenda**

- On the left with the white blocks, there you can find the display blocks and define blocks, where you can setup how many students you want to create.
- The blue boolean blocks are telling which requests has finished correctly
- The purple blocks are requests
- All yellow blocks are calculations/statements, like: evaluate if the requests http code is something. For loop collectors and activators, because you can active every request individual if you want to define your own flow path.

---

<div class="post-metadata">

**Author:** ![flows-daniel](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/flows-daniel/32/25516_2.png) [@flows-daniel](https://community.postman.com/u/flows-daniel)\
**Post date:** [January 16, 2024, 6:12pm UTC](https://community.postman.com/t/cant-update-body-variable-of-request-in-for-loop/56585/2 "2024-01-16T18:12:25Z")

</div>

Hi @nibhvdigitalimpact

Welcome to the forums!

A couple things here:

1. Regarding your loop, instead of using the for/collect blocks, you can transform the data directly in the evaluate block by selecting just the students elements of your first list. I’m just guessing at the structure of your data returned based on the types in the screenshot. If this doesn’t work for you, if you’re able to provide an example response, it would help me point you in the right direction.  

2. 

> I can’t connect a variable to a body variable of a request, it doesn’t failed when it’s a uri variable

Could you explain this a little more or show me a screenshot of what you mean?

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [February 15, 2024, 6:12pm UTC](https://community.postman.com/t/cant-update-body-variable-of-request-in-for-loop/56585/3 "2024-02-15T18:12:55Z")

</div>

Closed on February 15, 2024, 6:12pm UTC

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