# Mocking a server that does not contain the endpoint under test

**URL:** <https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307>\
**Category:** Help Hub\
**Created:** [August 25, 2020, 6:40pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307 "2020-08-25T18:40:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmskibba](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dmskibba](https://community.postman.com/u/dmskibba)\
**Post date:** [August 25, 2020, 6:40pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/1 "2020-08-25T18:40:52Z")

</div>

I am relatively new to Postman. I have a situation where we are testing endpoint calls to out back end. The processing of the endpoint call includes an endpoint call to a third party server. In some of tests we want to access the third party server. In other tests we want to mock the calls.

One possible solution is using Mountebank to create an impostor for the third party server. I know that will work, but that involves engaging and disengaging Mountebank outside of the test environment.

We would like to run the tests against a common test environment and I fear other users of the test environment would be affected by the impostor coming up and down in the background.

I am looking for a way to mock the third party server calls from Postman.

---

<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 26, 2020, 11:44am UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/2 "2020-08-26T11:44:31Z")

</div>

Is this what your looking for?

[Postman Mock Server documentation](https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/setting-up-mock/)

---

<div class="post-metadata">

**Author:** ![dmskibba](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dmskibba](https://community.postman.com/u/dmskibba)\
**Post date:** [August 26, 2020, 12:12pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/3 "2020-08-26T12:12:54Z")

</div>

I did look at that document before I posted the question. I may have interpreted it incorrectly, but the mocking appeared to be mocking the response for the current request. My issue is that the call I want to mock is not the call I am testing. See the diagram below:

![image001.png](https://us1.discourse-cdn.com/getpostman/original/2X/d/d78f33104afd8fab154bcd626faff3b00e5f2ee5.png)

To process the request, the backend service makes a call to a third party API. I need to mock those calls.

![image001.jpg](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpeg)

---

<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 26, 2020, 12:28pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/4 "2020-08-26T12:28:04Z")

</div>

Oh ok, I misread the question.

You own the backend service, right?

You can still create a mock server and have your backend service call it via code.

---

<div class="post-metadata">

**Author:** ![dmskibba](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dmskibba](https://community.postman.com/u/dmskibba)\
**Post date:** [August 26, 2020, 1:19pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/5 "2020-08-26T13:19:35Z")

</div>

The problem I am trying to solve is the transition between calling the third party server or using a mock server. I had hoped that we could drive the third party mocks from the test thus avoiding the transition.

We want to avoid putting mock-related code into the product code. Since we can accomplish this with Mountebank without modifying the product code, we will probably pursue that as a solution and live with the process to turn the Mountebank imposter on and off.

I am assuming that using a Postman mock server would involve some code changes to the back-end service. In the interest of completeness, I will look at the Postman Mocking doc to see what is involved.

Thank you for your help on this.

Dan

![image001.jpg](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpeg)

---

<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 26, 2020, 1:30pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/6 "2020-08-26T13:30:52Z")

</div>

Ok if you don’t want to modify the backend code, then Postman isn’t going to be able to help you out here.

I hope you find an easy solution that works for you!

---

<div class="post-metadata">

**Author:** ![dmskibba](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dmskibba](https://community.postman.com/u/dmskibba)\
**Post date:** [August 27, 2020, 8:44pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/7 "2020-08-27T20:44:31Z")

</div>

Can you point me to an example of what modification would need to be made to the backend code to use a Postman mock server?

Dan

![image001.jpg](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpeg)

---

<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 28, 2020, 11:39am UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/8 "2020-08-28T11:39:30Z")

</div>

That’s a pretty big ask. I don’t know what your backend looks like, how you’re making calls, what language you write in, etc…

What I can tell you is that Postman has a [generate code snippet](https://learning.postman.com/docs/sending-requests/generate-code-snippets/) functionality that will build the code you need to execute a request.

---

<div class="post-metadata">

**Author:** ![dmskibba](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dmskibba](https://community.postman.com/u/dmskibba)\
**Post date:** [September 9, 2020, 6:01pm UTC](https://community.postman.com/t/mocking-a-server-that-does-not-contain-the-endpoint-under-test/15307/9 "2020-09-09T18:01:49Z")

</div>

I am doing a proof of concept on the mocking of embedded endpoint calls made during the processing of a Postman request. Can you point me to documentation on how to set it up. We are using a Java back-end. The calls to be mocked are from a java micro-service to a third party API.

I have gone through [https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mock-with-api/](https://learning.postman.com/docs/designing-and-developing-your-api/mocking-data/mock-with-api/) and it seems to focus on mocking the result of the Postman call.

![image001.jpg](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f464dd1c7c382c015b3fc53eebe1cd1aadffee61.jpeg)
