If you didn’t already know about the power of the Postman console, then prepare yourself for debugging hyperdrive.
If at first you don’t succeed,
–Ritwij Sinha, Postman software engineer
The Postman console was originally designed to help debug Postman collections and API network calls. While we’ve made a number of improvements since that original release, the basic principle remains the same: The console is where you go to dig deep and debug issues when your API and API tests aren’t behaving the way you expect them to.
Meet the Console
At first glance, we have what appears to be a modest console. What lies behind this unassuming console is the power to see what’s going on under the hood. In a matter of moments, you’ll see helpful messages and details about the HTTP calls you make from Postman for more visibility while debugging.
To open the Postman console: Use the keyboard shortcut (CMD/CTRL + ALT + C) in the Postman app, or go to the application menu > “View” > “Show Postman Console”.
The debugging power
Every network call sent with Postman is logged in the console in both its raw and pretty form, replacing all the variables that you’ve used in the request. In the console, you can inspect headers, certificates, requests, and responses. You can even use the console to log messages.
Besides info about your network calls, most web developers are familiar with the idea of using a console for closer inspection and to see when something happens.
Web developers log messages for 2 general reasons:
- Making sure that code is executing in the right order.
- Inspecting the values of variables at a certain moment in time.
Log a message in the console
- Open the Postman console (CMD/CTRL + ALT + C).
- Under the Pre-request Script or Tests tabs of the Postman app, write an expression, like
console.log("I'm a boring old log").
- Click Send.
Here’s how the messages look in your console:
Whether you’re old friends with the Postman console or a newcomer, here are some of the latest enhancements:
- More information about network calls, like status codes, time, asynchronous calls from within a script, and redirects
- Support for new message types which can be filtered by type with highlighted errors and warnings
- Configurable settings to show or hide network calls and display timestamps
- Handling larger request and response bodies to view up to 10KB inline and up to 5MB when opened within the console
- Running record of the last 5,000 logs and 24 hours of history
Go Forth and Debug
Keeping the console open while you work in Postman will increase the visibility of your network calls and logged messages. That way, you can track request executions, exceptions, and errors as they happen. These real-time insights can help you identify and fix errors quickly.
The power of this console is limited only by your imagination, and also the last 5,000 messages and 24 hours.