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 :
Postman ignores request matching and just returns the response specified but I haven´t found how to do this?
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?
Hi Jimmy80 welcome to the community
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-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 :
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
Thank! That worked great!