Postman Tutorial Part 22 – Postman Console – Debugging And Logging
Debugging and logging are very important when you are trying to develop/test something. During development or Testing of any software or API, you may need to debug or log what is happening in between if actual behaviour is not as per expected behaviour. You must have heard of browser’s developer console or web console.
Postman also provides a console which is similar to browser’s developer console but Postman console is exclusively for API development. Official document of Postman says:-
” If an API or API test is not behaving as you expect, this would be the place where you will go to deep dive while debugging. As long as the console window is open, all your API activities will be logged here to see what’s going on under the hood. “
The Postman Console logs the following information:
- The actual request that was sent, including all underlying request headers and variable values, etc.
- The exact response sent by the server before it is processed by Postman
- The proxy configuration and certificates used for the request.
- Error logs from test or pre-request scripts
console.log()from inside scripts.
console.warn() at appropriate locations in the scripts will help extract the exact line of code that is acting up. If you know your way around
How to launch Postman Console?
- You can use key combinations as “ctrl+alt+c”.
- You can click on Console icon at bottom corner of left hand side.
3. You can also launch console using top menu:- “View- > Show Postman Console“.
If you follow any step above, you will see below screen:-
Let’s hit an API and see what are things are logged in to console:-
I will hit auth API of Restful-booker, You can refer my old posts to see about auth API.
Go to already opened Postman console. You will see an entry as below:-
Expand it by clicking on arrow:-
Let’s add some code in “Pre-request Script” and “Tests” tabs:–
Hit the request again.
We know already little about Pre-request and Test scripts execution sequence from this post. Above console shows the same thing.
You can clear the console using “Clear” button given at top side of right hand side.
More about API Testing in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.