postmanpostman-mocks

Using request data in Postman mock response


In my postman mock server I would like to use data from the request. Is this possible? I can't seem to find any reference to this scenario.

For example, my request includes a documentId value. I would like to capture that value and use it in the response.

Thanks.


Solution

  • Postman supports capture of URL path parameters for use in the response body, so e.g. if your example has https://my.example.com/v1/users/{{user_id}} in the URL, then you can use {{user_id}} in the response.

    That's about as far as it goes though. You can't at present use data from query parameters, headers or the request body in your responses.

    If you need to use other types of request data in your mock responses, you might want to check out MockLab. I've written up a detailed comparison of Postman mock servers and MockLab including a specific on dynamic responses and request data.