Skip to main content

Debug and Troubleshoot Unexpected Behavior

Learning Objectives

After completing this unit, you’ll be able to:

  • Reference console logs.
  • Read error messages.

Debug Unexpected Behavior

When an API is not behaving as you expect, use the Postman console to help with debugging. 

Open the console from the icon on the bottom left of PostmanConsole. Postman logs every request in both raw and pretty form. You can inspect headers, certificates, requests, and responses from these network calls. Let’s see it in action.

Send the second request in your collection and inspect the console output.

  1. Open Pictures from November 2023.
  2. Click Send.
  3. Then click Console at the bottom left of Postman.
  4. Expand your latest request to explore the log.
    Console open to the latest request of Pictures from November 2023
  5. Click Clear Clearto clear the console before running the next request.

Insert Console Statements

Using log statements at appropriate locations in your scripts helps identify the source of any issues. You can verify code is executing in the right order and inspect the values of variables at a certain moment in time.

  1. With Pictures from November 2023 still open, insert the following code on the first line of the Tests tab, console.log(`From the Tests tab, number of pictures is: ${pm.response.json().length}`)
  2. Send the request and inspect the console output. You’ll see the statement response.
    Console statement “From the Tests tab, number of pictures is: 30”

Continue Your Journey with Postman

You’ve gone through a lot in this module, from setting up your Postman workspace to testing, using variables, and debugging. Congratulations!

To continue your journey with Postman, here are some additional resources to check out.

  • Postman Learning Center: In addition to the docs, there are helpful guides and other support resources to level up your API skills.
  • Postman Community Forum: Postman has a large and active community, and someone might be willing to help if you ask nicely.

Resources 

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities