Capturing requests using the new Postman v0.9.4
Software complexity grows exponentially. As the size of the the code base increases, so does the interlocking between various parts of the system. Hence, finding out what’s going on exactly becomes critically important to debug your code and to ensure that everything works properly.
This is even more important for API calls. While most developers have a basic understanding of the API they are working with, things might go wrong due to a myriad number of reasons. The underlying library might not be configured correctly, a parameter might be missing or you might be sending data using the wrong encoding.
To help you avoid this, Postman now supports capturing your API calls through the PostmanProxy command line tool.
You can start the proxy with a single command, enable it inside Postman and see all HTTP calls which are made by a device configured to use the proxy. You can filter the calls through URL patterns and methods to focus only on the calls that you care about.
The entire setup takes a couple of minutes and requires absolutely no changes in your code. Here is what you have to do:
- Install the Postman packaged app v0.9.4. If you are already using the packaged app then make sure it’s updated. The app now needs TCP/UDP permissions too so if Chrome has disabled the app you have to re-enable it from the Tools menu.
- Install the PostmanProxy python package using “pip install PostmanProxy“. If you do not have pip installed, see instructions for installing it.
- Run the proxy using
pmproxy save --tcp_connection true
. This would start everything using the default values of 127.0.0.1 and port 8080.
4. Set your browser, computer or your phone to use the proxy. This varies between devices but a quick google search should give you the answer within seconds if you don’t know it already. If you are in a local wi-fi/LAN network then you can set the proxy to the local IP of the machine on which the proxy is running.
5. Click on the top right to show the proxy manager modal.
If everything works properly, you should see calls streaming into the history sidebar. You can stop streaming by hitting “Disconnect” or closing the proxy. You can even choose to add all calls to a particular collection. This is amazing for building new collections. You can build custom cases or flows for calls and share them as before. Once a request is inside, you get the power to work with using the tools which Postman provides.
PostmanProxy uses libmproxy, the excellent library provided by mitmproxy. The earlier proxy code was based on Twisted but I found working with mitmproxy much easier. Another advantage of mitmproxy is that it can help you monitor SSL connections. The documentation for that is available at the mitmproxy page. You need to follow the same instruction for PostmanProxy.
A couple of other options are available with PostmanProxy. You can save a collection file directly instead of syncing with Postman by using
. The earlier use case of the proxy, which was to bypass restricted headers, is also taken care of within this code. For this you will have to use
. To find out about more options use
This is still a work in progress and expect to see a lot of new stuff in the coming days around this feature. This has been tested on Linux and OS X.