# Saving request data sent to mock server

**URL:** <https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577>\
**Category:** Help Hub\
**Created:** [December 12, 2019, 5:30pm UTC](https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577 "2019-12-12T17:30:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![keyulpax](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@keyulpax](https://community.postman.com/u/keyulpax)\
**Post date:** [December 12, 2019, 5:30pm UTC](https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577/1 "2019-12-12T17:30:37Z")

</div>

> **Archived topic — some details may be out of date.**  
> Mock servers built from saved collection examples are still supported. Postman now also has **code-based mocks** : JavaScript request handlers plus a `config.yaml`, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (`postman mock generate`) and run it (`postman mock run`). See [About mocks](https://learning.postman.com/docs/design-apis/mock-apis/mocks/overview) and [Create a mock](https://learning.postman.com/docs/design-apis/mock-apis/mocks/create-a-mock).  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) can build and run mocks for you.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

I am trying to implement the following scenario in the postman.

_Scenario:_

1. Setup a mock server

2. Send a request to the mock server

3. Access the data received on the mock server

4. Store that data to a global variable and use it later in the testing

Step 1 and step 2 are done. but stuck at step 3.

**How should I access the data from the request sent to the mock server?**

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [December 15, 2019, 4:21pm UTC](https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577/2 "2019-12-15T16:21:39Z")

</div>

Can you maybe explain which problem / scenario you are trying to solve?

---

<div class="post-metadata">

**Author:** ![tra](https://avatars.discourse-cdn.com/v4/letter/t/58956e/32.png) [@tra](https://community.postman.com/u/tra)\
**Post date:** [September 29, 2020, 4:32pm UTC](https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577/3 "2020-09-29T16:32:02Z")

</div>

Hi vdespa,  
I haven’t found answer but I am dealing similar usecase keyulpax.

I have setup mock server using postman I call it e.g. by this url {{url}}/get?foo=bar.  
If I call requeste from postman it is fine and I can process parameter by “Tests” in Request.  
But when the url is called from browser, I can’t use Pre-Request Script or Tests anymore.  
The aim is to catch parameters from url directly in response as save it as variable. Is that possible?

Thanks

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [October 2, 2020, 5:31pm UTC](https://community.postman.com/t/saving-request-data-sent-to-mock-server/9577/4 "2020-10-02T17:31:36Z")

</div>

@tra - you can use scripts and variables only within Postman.
