# I need to send dynamic values into the request body

**URL:** <https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103>\
**Category:** Help Hub\
**Tags:** automation, pmsendrequest\
**Created:** [August 18, 2020, 10:05am UTC](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103 "2020-08-18T10:05:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Balakrishna.Mandala](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Balakrishna.Mandala](https://community.postman.com/u/Balakrishna.Mandala)\
**Post date:** [August 18, 2020, 10:05am UTC](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103/1 "2020-08-18T10:05:09Z")

</div>

Hi,

I am sending a request and it returns few records in response and it is displayed in page 1. I have multiple pages of response. After getting the first page response, i am printing the request body using “console.log(JSON.stringify(pm.request));” and copying it from the console and using it in pm.sendRequest() function to run the request inside a for loop. I want to pass a different page number to the request for every run inside the loop.

Below is my request body:

{“url”:{"hidden intentionally},

“header”:[hidden intentionally],

“method”:“POST”,

“body”:{“mode”:“graphql”,“graphql”:  
{“query”:“query ($start: String!, $end: String!, $page: Int!) \r\n{\r\n itemClassUpdates(start: $start, end: $end, page: $page) \r\n {\r\n page\r\n totalPages\r\n start\r\n end\r\n events \r\n {\r\n event\r\n itemClass\r\n {\r\n handle\r\n code\r\n erpCode\r\n description\r\n discontinued\r\n createUser\r\n createDate\r\n updateUser\r\n lastModified\r\n itemSubclasses\r\n {\r\n handle \r\n classHandle\r\n code\r\n erpCode\r\n description\r\n defaultUnitHandle\r\n discontinued\r\n createUser\r\n createDate\r\n updateUser\r\n lastModified\r\n }\r\n }\r\n }\r\n }\r\n}”,  
“variables”:“{\r\n "start": "2020-08-13T13:28:10Z",\r\n "end": "2020-08-13T13:55:18Z",\r\n "page" : 1\r\n \r\n}”},  
“options”:{“graphql”:{}}  
}  
}

Is this possible to send dynamic page numbers through pm.sendRequest function into page variable in postman?

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [August 31, 2020, 9:10am UTC](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103/2 "2020-08-31T09:10:53Z")

</div>

Hello,

Yes it is possible, but depends on your API design as well. It is Pagination.

In your Query you have ($start: String!, $end: String!, $page: Int!)

Try defining a variable for your parameters and do a if loop till it reaches the end.

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [August 31, 2020, 11:49am UTC](https://community.postman.com/t/i-need-to-send-dynamic-values-into-the-request-body/15103/3 "2020-08-31T11:49:38Z")

</div>

Do you know the total page count? If you do, you could set the variable like this:

```auto
const pageNumber = Math.trunc(Math.random() * totalPageCount);
pm.collectionVariables.set('pageNumber', pageNumber);
```
