# Flow "Request" Block: Response Body displays sub-request

**URL:** <https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840>\
**Category:** Help Hub\
**Tags:** tests, response, bug, postman-flows\
**Created:** [July 1, 2024, 9:03am UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840 "2024-07-01T09:03:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![material-operator-66](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@material-operator-66](https://community.postman.com/u/material-operator-66)\
**Post date:** [July 1, 2024, 9:03am UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/1 "2024-07-01T09:03:07Z")

</div>

Hey! Long time watcher first time caller.

- I created a “Get All” request to get a list of objects. In the request’s "Post-request-scripts (tests) I’m executing “Get by ID” requests.  
When executing this Request using the “Flows” feature, the response body displays one of the “Get by ID” responses instead of the “Get All” response.

- Platform: OS X 23.5.0, 11.2.1-ui-240611-2311

- Script:

```auto
var responseData = pm.response.json();
# Test for validating that each 'id' field in the response data is a string and exists
responseData.data.forEach(function(tag) {
  pm.test(`'id' field should exist and be a string for tag ${tag.id}`, function () {
    pm.expect(tag).to.have.property('id').that.is.a('string');
  });
});

```

- Response of “Get All” request:  

- Response body in “Flow”:

---

<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:** [July 1, 2024, 5:42pm UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/2 "2024-07-01T17:42:16Z")

</div>

Hi @material-operator-66

Welcome to the forums!

Can you run your request in flows with all tests and scripts disabled/removed and see if it returns just a single record instead of the expected list?

---

<div class="post-metadata">

**Author:** ![material-operator-66](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@material-operator-66](https://community.postman.com/u/material-operator-66)\
**Post date:** [July 2, 2024, 8:07am UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/3 "2024-07-02T08:07:06Z")

</div>

Sure! This is the same flow after I commented out all of the tests:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/5/a52d4e7c6675a16348b898b7850a32f506bd6f6d.png)

---

<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:** [July 2, 2024, 7:55pm UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/4 "2024-07-02T19:55:57Z")

</div>

Hi @material-operator-66

Do you have any other tests that you’re running that could be interfering with the response? I re-constructed an API similar to yours and added in your test and the response came back with the list.

If you run with just this test enabled does the issue still happen?

---

<div class="post-metadata">

**Author:** ![material-operator-66](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@material-operator-66](https://community.postman.com/u/material-operator-66)\
**Post date:** [July 3, 2024, 12:09pm UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/5 "2024-07-03T12:09:43Z")

</div>

Created a new flow that only executes this one request.  
With Tests commented out:  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/a/da223f084adda73f7318e6ee2700bf837641295d.png)  
With tests enabled:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/7/47b8260e5022784f5d3bac6271b9614b0719b174.png)

Script:

```auto
const tagList = pm.response.json().data;

// Ensure that the response contains an array of tags
pm.test("tag list should be an array", function () {
    pm.expect(tagList).to.be.an('array');
});

// Iterate over each tag in the list
tagList.forEach(function(tag) {
    const tagId = tag.id;

    // Send a request to get the tag by ID
    pm.sendRequest({
        url: pm.environment.get('base_url') + 'tags/' + tagId,
        method: 'GET',
        header: {
            'x-api-key': `${pm.environment.get("token")}` // Add your API key here
        }
    }, function (err, res) {
        // Parse the response
        const tagDetails = res.json();

        // Run your tests on the tag details response
        pm.test(`Response status code should be 200 for tag ${tagId}`, function () {
            pm.expect(res).to.have.status(200);
        });
        });

    });
});

```

Tell me if I can be of any service otherwise.  
If you want to video-call with screen-sharing, I’m available GMT+3 10:00-19:00 😃

---

<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:** [July 3, 2024, 6:58pm UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/6 "2024-07-03T18:58:29Z")

</div>

Hi @material-operator-66

Thank you for providing that.

The sendRequest function will override the Send Request block’s output with the last run request.

I recommend performing this test as part of the flow instead 🙂

There are several ways to achieve it but here’s one implementation:

 ![Screenshot 2024-07-03 at 11.56.48 AM](https://us1.discourse-cdn.com/getpostman/original/3X/5/e/5e22aceffc778aeeb083548b635d0cc6dbc84ff6.png)

You could also use an If block to check the status after each request and log the non 200 ones if you would prefer.

---

<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:** [August 2, 2024, 6:58pm UTC](https://community.postman.com/t/flow-request-block-response-body-displays-sub-request/62840/7 "2024-08-02T18:58:52Z")

</div>

Closed on August 2, 2024, 6:58pm UTC

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