Copy incoming request as exemaple?

Hi,

I have a Postman mock that are called by my C# application, the problem is that I don’t know how the request really looks like so I can´t add an example to postman collection for the Mock. Is there a way to copy incoming request as example for the mock collection to avoid the “no matching response”? I already got help to ignore the request matching but it would be nice if I could make it work without adding special header("x-mock-response-id) in my c# app.

Regards

Hi @Jimmy80

Inside the mock server have you tried looking in the logs?
You should see the information for both request and response.

Yes, but i’m not sure how to copy\paste it to a proper request message? I suppose it will have to perfect match. So how do the raw request look like in this example :

REQUEST HEADERS
x-forwarded-for: “xxxxxxxxx”
x-forwarded-proto: “xxxxxxxxx”
x-forwarded-port: “xxxxxxxxx”
host: “912824e2-3732-4a9a-8631-624048b05f03.mock.pstmn.io”
x-amzn-trace-id: “Root=4-640b69b0-1d211b075faab71a2883ed3f”
content-length: “854”
accept: “application/json”
x-mock-response-id: “3459264-c1c7a8a5-c327-4368-9e0e-908520d69271”
content-type: “application/json”

REQUEST BODY
{header: {…}, identification: {…}, scheduling: {…}…}
header: {…}
cha_status: “Creation”
my_status: “Created?”
my_installation: “N”
identification: {…}
id: “1”
firstname: “Me”
lastname: “Me”
scheduling: {…}
number: “2”
planned_code: “wer2”

You could grab the JSON object from the test tab using this;

console.log(JSON.stringify(pm.request));

//or

console.log(JSON.stringify(pm.request.body));
console.log(JSON.stringify(pm.request.headers));

Does that help?

So I select my collection and click the Tests tab, in here I add

console.log(JSON.stringify(pm.request));

What do i do then? I have tried to send requests to the Postman Mock and I have tried to “run a test” under Collection > Runs

The Collection have a Post request that is empty at this point, here is also a test tab but it seems to be bound to the GET/POST request. On this case I need to listen to incoming request from my client and then take this request and add it to expected request in the collection. This to avoid having to point out a the specific response that my client expects.

My apologies I misread your original post and was multitasking when I replied.

The console.log would work if running from Postman.
If the webhook is triggered from elsewhere I will have to have a think, as Im not sure on the solution (or if there is a solution).

I have created a collection that I created a Postman Mock service from. My .NET client can send messages to the Postman Mock Service but there is no request to match it with so it fails. To solve this I had to add a header on the .NET client that points out the response from postman it expects. This works fine but it would be great if I did not have to have special code in my .NET client to make test calls to postman mock service.

What I need is to get the request as it looks like in the wire, paste it in i postman so it can be matched with the client request so that the proper response can be returned without special header.

Not had a chance to look yet, but just wondered if you have tried (or if it would be of use) the Postman Interceptor?

You may be able to capture your traffic this way.

From what I understand the Postman Interceptor is a Chrome extension, my project do not use any browser at all? It uses .net HttpClient to send a message to a mock service.