In programming, debugging is the process of identifying and fixing an error in the code. For API consumers and producers, most of the effort is spent on locating the root cause of the issue based on what can be observed.
In an ideal scenario, there is rigorous testing and monitoring in place to alert you when something goes wrong. But even if you don't have this level of observability, let's learn about three ways to increase visibility when debugging APIs.
Basic familiarity with Postman and APIs
What You'll Learn
Explore methods for understanding API behavior, including updating user inputs to change the API response
Debug and troubleshoot unexpected behavior
Establish visibility for monitors, webhooks, and CLI
Enter a label for your fork and select the workspace to fork the collection:
For the remainder of this tutorial, follow along in the example collection with this video.
Inspect inputs and outputs for API calls
Postman is most commonly used as an API client to explore APIs. Postman allows you to manipulate inputs and inspect the outputs to better understand the relationship between the two. Here are some ways that you can debug more easily using Postman as an API client.
Select the collection you just forked to your workspace, called "Advanced API Debugging", and expand the folder "Client".
Which log statements are accepted in the Postman console ?
console.log()console.info()console.warn()console.error()All of the above
Mock servers for debugging and testing
Mock servers allow you to simulate API behavior using Postman servers. Mocks are frequently used in debugging to simplify a problem or isolate a system under test. Here is how you can debug APIs using Postman mock servers.
Select the collection you just forked to your workspace, called "Advanced API Debugging", and expand the folder "Mock servers".