I need to receive callback requests into my script and respond to them

In the api that I need to test when I send a request I immediately receive a receive a response with a transactionID, no matter transaction succeeded or not. Along with my request I send a CallbackURL to the server where I expect the actual transaction result to be called back. The server will do a PUT request back to the CallbackURL that I have provided with the transactionID and the actual response or error.

So the question is, can I have such kind of scenarios in my postman tests?
I guess I should run a web server and expose an endpoint which will expect a PUT request and I should get the body of this PUT request in my tests to check it, and respond back to it with success.

In other words, within my script I need to perform the following actions:

  1. Do a request to the server passing a callback URL
  2. check the immediate response from the server and keep the returned transactionID
  3. Have a webserver run with and endpoint that I passed as a callback URL
  4. expect a request to that endpoint with transactionID and actual response
  5. Check that the response is what I actually expected
  6. Respond to the request with success

I was thinking about Postman Mock server, but seems it is not designed for such usage.
I also think may be I can run some JS webserver inside the postman sandbox…

Actually I am very new to postman testing and I am really confused about this kind of issue. Is it even possible to do this with postman or I need something else?

Hi @andranik.h89,

Welcome to the Postman community! You can send multiple requests to the server, append callbacks and handle the responses in the Pre-request scripts or Tests tab using the pm.sendRequest function whose usage is outlined in the given documentation: https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/#pmsendrequest
Hope that helps!