I’m using the mock server, and my outbound API that I’m targeting at the server generates a unique transaction ID for each outbound call. I’m trying to take that unique parameter as well as take the first name and last name and pass it back in the response. This seems like something that should be pretty easy and straightforward, but I’m not finding anything after a few days of playing and sifting through the forums.
The trasaction ID will be unique every time. I need to return this value back with the response body. I would like the response body to work something like this:
@bpricilla That does not seem to work for me. The value returned with the response is “”
I’ve made this example really simple just to illustrate. And, I’m assuming you meant to use the pre-request script, or is there another area I should be using this?
create an example that will return a 200 response which includes some of the request parameters in the response body that are captured from the inbound requests.
hit the mock server with a request from my personal api that I’m developing which sends a uniquie ID for each outbound request.
I’d like the mock server to return these parameters in it’s immediate 200 response body. (very much like posman-echo.com is doing in your example)
Basically, how would I set up my postman mock server to do exactly what postman-echo just did.
I tried using the pre-request script as you’ve shown here and it only sends back “” as a value.
Hi @joey,
I’ve looked into trying to do this kind of dynamic response in a mock server several times in the last 12 months and concluded that this functionality is not currently supported. (maybe someone from the Postman team can confirm? @danny-dainton ?). For dynamic mocking like you describe, you may want to look for service virtualisation tools rather than mocking tools until Postman extend this feature into their mocks.
@joey - is this close to what you’re trying to do: #5 Transfer value from request to response? Requires updating an example in a pre-request script using pm.sendRequest() and the Postman API.
@cgopinath Shouldn’t this be a new question, as it doesn’t seem to relate to this topic.
However, the error is telling you what is wrong. You have a header called SoapAction, and it doesn’t have a value. I’m guessing the API will not accept this being null.