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 

계속해서 무료로 학습하세요!
계속 진행하려면 계정을 가입하세요.
얻을 수 있는 이점
  • 커리어 목표에 대한 개인화된 권장 사항 제공받기
  • 실습 과제 및 퀴즈를 통해 스킬 연습
  • 진행 상황을 추적하고 고용주에게 공유
  • 멘토십과 커리어 기회에 연결