Ignore request matching or copy incoming request?

Hi,

I have created a simple Mock service in Postman and I can see that I get requests from my C# app. The problem is that do not know how the request really looks like from my C# app so instead I get a No matching requests (404) from postman. I see 2 possible solutions :

  1. Postman ignores request matching and just returns the response specified but I havenĀ“t found how to do this?

  2. Fetch the request from my C# app and use it as a expected request in postman. Postman do however not show the full request and I do not know how to get it any other way?

Suggestions?

Hi Jimmy80 welcome to the community :wave:

If you are not really interested in matching any patterns and you just want to retrieve to the example you defined, you can retrieve the response via its ID or name by passing x-mock-response-name or x-mock-response-id in your requestā€™s headers

I got a collection that the mock is based on, in this collection I got a default post request and this have a default seponse. No aditional headers or anything have been added.

I have found how to add a DefaultRequestHeaders to my httpClient :

httpClient.DefaultRequestHeaders.Add(ā€œx-mock-response-nameā€, ā€œdefaultā€)

But iā€™m not sure how this should be matched in postman mock service? I suspect that I need to add some kind of name\id to the post example. I tried adding x-mock-response-name : default here as well but that does not help.

Can you try x-mock-response-id and use your exampleā€™s id?

How to find an ID of an element

After that, you should attach it to your headers as ā€˜x-mock-response-nameā€™: ā€œResponseID.ā€

Depending on what type of code you are trying to generate, you can try using Postmanā€™s Code Snippet feature.

Generating client code

2 Likes

Thank! That worked great!

1 Like