{"id":90814,"date":"2021-05-10T18:46:42","date_gmt":"2021-05-10T18:46:42","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=90814"},"modified":"2022-05-02T20:37:34","modified_gmt":"2022-05-02T20:37:34","slug":"documenting-testing-apis-postman","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/documenting-testing-apis-postman\/","title":{"rendered":"Documenting and testing APIs  with Postman"},"content":{"rendered":"<p>There\u2019s no question whether testing is important to the evolution of your APIs, especially when they come in an <a href=\"https:\/\/www.red-gate.com\/simple-talk\/sysadmin\/devops\/how-automating-your-tests-improves-productivity\/\">automated manner<\/a>. Many teams also lack documentation of all sorts to guide new people on understanding and using the endpoints. This article covers documenting and testing APIs with Postman.<\/p>\n<p>You probably have heard about <a href=\"https:\/\/www.postman.com\/\">Postman<\/a>, the famous collaboration platform for API development and testing. Yes, testing. Many developers don\u2019t know the power that Postman can add to their daily lives in automating API tests. The possibility of sharing your test collections along with your team and working together on them is even better.<\/p>\n<p>In this article, you\u2019re going to dive into the universe of documenting and testing your APIs with Postman. You\u2019ll also get to see some nice tips on discovering some hidden features of the tool that\u2019ll facilitate your automation and increase productivity.<\/p>\n<h2>Setup<\/h2>\n<p>The first step includes Postman <a href=\"https:\/\/www.postman.com\/downloads\/\">installation<\/a>. Although there\u2019s a web version available, the Desktop version is faster. Additionally, I\u2019d advise you to create an account and stay logged in because that\u2019ll allow Postman to keep your collections and tests synched.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1675\" class=\"wp-image-90815\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image.png\" \/><\/p>\n<p><strong>Figure 1.<\/strong> <strong>Postman home screen<\/strong><\/p>\n<h2><a id=\"post-90814-_heading=h.1fob9te\"><\/a>The API<\/h2>\n<p>For this article, you can use whatever API you\u2019ve created or are working with. The only requirement is that you have, at least, most of the HTTP verbs related to CRUD operations. However, to demonstrate, I\u2019ll stick to an API made with ASP.NET, the CRUD API I\u2019ve developed before in another article: <a href=\"https:\/\/www.red-gate.com\/simple-talk\/dotnet\/net-development\/creating-asp-net-apps-with-react\/\">Creating ASP.NET Apps with React<\/a>.<\/p>\n<p>Make sure to <a href=\"https:\/\/github.com\/iamjuliosampaio\/ReactASPNET\/\">clone the project<\/a> to your machine. Then, <em>cd<\/em> into the <em>\\ReactASPNET\\ReactASPCrud\\ReactASPCrud<\/em> folder, and run the following command:<\/p>\n<pre class=\"lang:c# theme:vs2012\">dotnet run<\/pre>\n<p>Once the command terminal prints the \u201c<em>Application started<\/em>\u201d message, the app is up and running at <a href=\"http:\/\/localhost:5000\">http:\/\/localhost:5000<\/a>.<\/p>\n<h2><a id=\"post-90814-_heading=h.3znysh7\"><\/a>Postman: First steps<\/h2>\n<p>Postman is divided into workspaces. Each workspace corresponds to a set of configurations, collections, and endpoints specific to it. It\u2019s a great way to separate your APIs from the ones of your workplace, for example.<\/p>\n<p>Right at the home page, click the <em>Workspaces<\/em> option and select <em>My Workspace<\/em> at the following screen.<\/p>\n<p>The two main sections you\u2019ll be working with are:<\/p>\n<ul>\n<li><em>Collections<\/em>: Postman collections are a set of endpoints that have things in common and make sense to stick together;<\/li>\n<li><em>Environments<\/em>: The environments are a great feature Postman provides you to set up specific configs for each environment you may have (e.g., local, development, test, etc.).<\/li>\n<\/ul>\n<h2><a id=\"post-90814-_heading=h.2et92p0\"><\/a>Environments<\/h2>\n<p>Since the collections make use of environment variables, start with them. On the left panel, click the <em>Environments<\/em> section and then click on the link <em>Create Environment<\/em> as shown in Figure 2.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"1002\" class=\"wp-image-90816\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-1.png\" \/><\/p>\n<p><strong>Figure 2.<\/strong> <strong>Creating a new environment<\/strong><\/p>\n<p>That\u2019ll open a new tab with a field to set a name for this environment. Call it <em>LOCAL<\/em> since it\u2019ll store the configs for your localhost API. If you host your API in different envs such as development and production, you may create a new environment for each one of them.<\/p>\n<p>Environments are nothing more than a repository of key-value variables. Create the first one, a variable to store the API URL, as seen in Figure 3 .<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"674\" height=\"195\" class=\"wp-image-90817\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-2.png\" \/><\/p>\n<p><strong>Figure 3.<\/strong> <strong>Creating the first environment variable<\/strong><\/p>\n<p>As you can see, there are three fields to fill:<\/p>\n<ol>\n<li><em>Variable<\/em>: that\u2019s the name of the variable you\u2019ll use throughout the collections.<\/li>\n<li><em>Initial value<\/em>: whenever no value is provided for that variable, this would be used instead.<\/li>\n<li><em>Current value<\/em>: this value overrides the previous. That\u2019s the value that\u2019ll be populated when a test dynamically sets the variable, as you\u2019ll see later in this article.<\/li>\n<\/ol>\n<p>Great! Save the file (<em>Ctrl + S<\/em>) and close the tab for now.<\/p>\n<p>After you save it, you may notice that the combo box at the top of the panel has now a new value, as shown in Figure 4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"626\" height=\"320\" class=\"wp-image-90818\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-3.png\" \/><\/p>\n<p><strong>Figure 4.<\/strong> <strong>The new LOCAL environment<\/strong><\/p>\n<p>Remember to select the proper environment every time you\u2019re testing an endpoint; otherwise, the test will fail to locate the variables. In this case, you\u2019ll be using the LOCAL environment just created.<\/p>\n<p>If you desire to see the initial and current values of a given variable, just click on the eye button on the right side of the combo box.<\/p>\n<h2><a id=\"post-90814-_heading=h.tyjcwt\"><\/a>Collections<\/h2>\n<p>Now, get back to the <em>Collections<\/em> section. When you click it, you may see a plus button, as shown in Figure 5. Use this button when you need to create a new collection.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"942\" height=\"422\" class=\"wp-image-90819\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-4.png\" \/><\/p>\n<p><strong>Figure 5.<\/strong> <strong>Creating a new Postman collection<\/strong><\/p>\n<p>Again, a new tab will show up. Give it a name (e.g., <em>React ASP CRUD<\/em>), and it will look like the one shown in Figure 6.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"291\" class=\"wp-image-90820\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-5.png\" \/><\/p>\n<p><strong>Figure 6.<\/strong> <strong>New Collection created<\/strong><\/p>\n<p>Pay attention to the right-side panel called <em>Documentation<\/em>. This is where Postman keeps the documentation features which resumes to Markdown-like text.<\/p>\n<p>Postman understands <a href=\"https:\/\/guides.github.com\/features\/mastering-markdown\/\">GitHub Markdown<\/a> content which is great to create rich API documentation, including images, code blocks, links, tables, etc.<\/p>\n<p>I\u2019ll cover more on documenting the APIs later. For now, focus on creating new API endpoints with Postman to test them. For this, right-click the created collection and select the option <em>Add request<\/em> (Figure 7).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"1502\" class=\"wp-image-90821\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-6.png\" \/><\/p>\n<p><strong>Figure 7.<\/strong> <strong>Adding a new request<\/strong><\/p>\n<p>A new tab window will show up this time with the main field for you to select the HTTP verb of your endpoint request and provide the URL.<\/p>\n<p>Remember the previously created env variable to store the API URL. Well, you can use it to avoid duplicating such information in every endpoint.<\/p>\n<p>Figure 8 demonstrates how you can make use of an env variable.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1196\" height=\"652\" class=\"wp-image-90822\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-7.png\" \/><\/p>\n<p><strong>Figure 8.<\/strong> <strong>Accessing the <em>apiUrl<\/em> env variable<\/strong><\/p>\n<p>The figure also shows what happens when you hover the variable on Postman. It displays both initial and current values of that variable, which is very useful.<\/p>\n<p>Go ahead and finish up your URL by typing:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">{{apiUrl}}\/users<\/pre>\n<p>Hitting the <em>Send<\/em> button will trigger the request to your localhost app. Since you\u2019re dealing with an API that\u2019s HTTPS, proper certificate verifications will be done by Postman.<\/p>\n<p>That\u2019s not the focus here. So, if it displays the error message shown in Figure 9, just click the <em>Disable SSL Verification<\/em> link, and you\u2019ll be fine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1450\" height=\"678\" class=\"wp-image-90823\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-8.png\" \/><\/p>\n<p><strong>Figure 9.<\/strong> <strong>SSL certificate error message<\/strong><\/p>\n<p>When you click the <em>Send<\/em> button once more, the results shown in Figure 10 will show up.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1550\" class=\"wp-image-90824\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-9.png\" \/><\/p>\n<p><strong>Figure 10.<\/strong> <strong>Getting the list of users successfully<\/strong><\/p>\n<p>You may repeat this process for each of the API endpoints you want to test. For example, to get a single and specific user by id (say <em>1<\/em>), you may use another endpoint:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">{{apiUrl}}\/users\/1<\/pre>\n<p>You can easily do that by duplicating the previous request via Postman. It offers this functionality by right-clicking the <em>Get Users<\/em> request and selecting the <em>Duplicate<\/em> option (Figure 11).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"622\" height=\"618\" class=\"wp-image-90825\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-10.png\" \/><\/p>\n<p><strong>Figure 11.<\/strong> <strong>Duplicating a request on Postman<\/strong><\/p>\n<p>Then, you can change the request name (<em>Get Users By Id<\/em>), change the URL, and hit the <em>Send<\/em> button again, all shown in Figure 12.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1302\" class=\"wp-image-90826\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-11.png\" \/><\/p>\n<p><strong>Figure 12.<\/strong> <strong>Get user by id endpoint request<\/strong><\/p>\n<p>When it comes to creating a new user, things change a little bit since it\u2019s a new HTTP method being used, the <em>POST<\/em>.<\/p>\n<p>Figure 13 shows all the available HTTP methods that Postman provides internally.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1534\" height=\"1360\" class=\"wp-image-90827\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-12.png\" \/><\/p>\n<p><strong>Figure 13.<\/strong> <strong>List of Postman HTTP methods<\/strong><\/p>\n<p>Other than that, a POST request also requires a JSON payload going within the request\u2019s body. You can set it up by going to the <em>Body<\/em> tab, selecting the <em>raw<\/em> option, and, finally, the <em>JSON<\/em> option on the combo box.<\/p>\n<p>Follow up Figure 14 to see instructions for that.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1652\" height=\"822\" class=\"wp-image-90828\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-13.png\" \/><\/p>\n<p><strong>Figure 14.<\/strong> <strong>Selecting proper JSON body type<\/strong><\/p>\n<p>Then, fill in the text area with some JSON to create a new user and hit the <em>Send<\/em> button once more. That is enough to create the user and receive a 201 status, as shown in Figure 15.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1168\" class=\"wp-image-90829\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-14.png\" \/><\/p>\n<p><strong>Figure 15.<\/strong> <strong>Creating a new user with Postman<\/strong><\/p>\n<p>Great! I\u2019ll let you work with the other two remaining endpoints: to update and delete users.<\/p>\n<h2><a id=\"post-90814-_heading=h.3dy6vkm\"><\/a>Postman examples<\/h2>\n<p>Another great feature Postman provides is called Postman examples. An example is simply a request that you ran and produced a specific result which you may find useful to document for other devs willing to understand your API.<\/p>\n<p>For example, take the <em>get user by id<\/em> endpoint. When you send the request, and it returns with success, you may notice that there\u2019s a link called <em>Save response<\/em> close to the status code (Figure 16).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"908\" height=\"342\" class=\"wp-image-90830\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-15.png\" \/><\/p>\n<p><strong>Figure 16.<\/strong> Saving a response as an example<\/p>\n<p>If you click the <em>Save as example<\/em> option, it\u2019ll open a new tab for the example. In other words, an example works as a screenshot of that request\/response. Rename it to a more concise name such as <em>200 &#8211; Get user by id successfully<\/em>.<\/p>\n<p>The 200, in this case, helps to quickly identify what that example is about. If you try to get a user whose id is \u201cabc\u201d, for example, that\u2019ll produce a different response, as you can see in Figure 17.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"1025\" class=\"wp-image-90831\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-16.png\" \/><\/p>\n<p><strong>Figure 17.<\/strong> <strong>Getting a user with an invalid id<\/strong><\/p>\n<p>This time, you may save the response as a new example with a different name: <em>400 &#8211; Invalid user id<\/em>, and so forth.<\/p>\n<h2><a id=\"post-90814-_heading=h.1t3h5sf\"><\/a>Documenting<\/h2>\n<p>All the changes so far were structural, i.e., focused on paving your way to having enough endpoints to document and test.<\/p>\n<p>As said before, Postman makes use of Markdown syntax to document stuff. When you click the documentation button on the right of the window, then go to edit, you should find what\u2019s shown in Figure 18 .<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"1256\" class=\"wp-image-90832\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-17.png\" \/><\/p>\n<p><strong>Figure 18.<\/strong> <strong>Markdown documentation on Postman<\/strong><\/p>\n<p>Go ahead and type the same content into yours. When you save the example above, it will turn into the following visual representation:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"444\" height=\"829\" class=\"wp-image-90833\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-18.png\" \/><\/p>\n<p><strong>Figure 19.<\/strong> <strong>Postman example documentation<\/strong><\/p>\n<p>Cool, isn\u2019t it? One thing to notice is that Postman adds its style to things like code blocks, for example, allowing the users to copy\/paste easily.<\/p>\n<p>Note also that a reference to the <code>{{apiUrl}}<\/code> env variable was intentionally added . As you can see, the result is that Postman translates whatever env variable you add to your docs. More than that, it\u2019ll dynamically change every time you switch from one environment to another.<\/p>\n<p>At the end of it, you can find the list of requests that belong to this current collection. And guess what? You can add docs to each endpoint individually too.<\/p>\n<p>Time to test it out! Click the <em>View complete collection documentation<\/em> link at the bottom of the window. That\u2019ll open a new tab with the complete documentation, very similar to other tools such as Confluence, for example.<\/p>\n<p>Other than a broader view of the documentation, you also have some other features that you didn\u2019t have on the shorter visualization.<\/p>\n<p>Scroll down to the <em>Get Users By Id<\/em> request. Since you\u2019ve set up two Postman examples for this request before, now you get to see a combo box with the two of them for you to pick (Figure 20).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1480\" height=\"1190\" class=\"wp-image-90834\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-19.png\" \/><\/p>\n<p><strong>Figure 20.<\/strong> <strong>Selecting one of the examples on Postman<\/strong><\/p>\n<p>Postman will then update the request and response data according to the example you select.<\/p>\n<p>Another interesting feature is that you can select the programming language (among many provided by Postman) from which you\u2019d like to have the endpoints being accessed. The default is cURL.<\/p>\n<p>At the top of the documentation tab, there\u2019s this <em>LANGUAGE<\/em> combo box, and when you click it, you will see the list of options as shown in Figure 21.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"866\" height=\"812\" class=\"wp-image-90835\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-20.png\" \/><\/p>\n<p><strong>Figure 21.<\/strong> <strong>List of available languages on Postman<\/strong><\/p>\n<p>If you select the <em>C# &#8211; RestSharp<\/em> option, for example, the Postman examples will update accordingly.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1436\" height=\"1320\" class=\"wp-image-90836\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-21.png\" \/><\/p>\n<p><strong>Figure 22.<\/strong> <strong>Autogenerated RestSharp code<\/strong><\/p>\n<h2><a id=\"post-90814-_heading=h.4d34og8\"><\/a>Testing<\/h2>\n<p>Postman is not only good at running requests and documenting them. It also offers great options to test your APIs and create entire test suites for your QA team.<\/p>\n<p>It\u2019s usually best practice to separate your tests from the ordinary endpoints since they change in different ways. Because of this, create a new collection called <em>Test Suites<\/em>. Then, duplicate the <em>New User<\/em> and <em>Get Users By Id<\/em> endpoints to there. The purpose here is to create a test suite that will first create a new user and test if shows up in the database.<\/p>\n<p>It\u2019s also good to enumerate your endpoints since the order is essential here. This way, Postman can\u2019t mess it up.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"618\" height=\"200\" class=\"wp-image-90837\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-22.png\" \/><\/p>\n<p><strong>Figure 23.<\/strong> <strong>A new suite of enumerated tests<\/strong><\/p>\n<p>This suite is aimed to be run several times and always work. Because of that peculiarity, you can\u2019t always pass the same data since backend validations may throw errors for duplicate information, such as email, for example, which is supposed to be unique.<\/p>\n<p>Change the body of the first endpoint to the following:<\/p>\n<pre class=\"lang:c# theme:vs2012\">{\r\n\t\"name\": \"{{$randomFirstName}} {{$randomLastName}}\",\r\n\t\"email\": \"{{$randomEmail}}\",\r\n\t\"document\": \"293920230\",\r\n\t\"phone\": \"{{$randomPhoneNumber}}\"\r\n}<\/pre>\n<p>You may be wondering about these new variables that you haven\u2019t declared. That\u2019s right; Postman also provides you with some default variables for various purposes such as random emails, usernames, addresses, etc. This way, you won\u2019t risk duplicating any data at any time.<\/p>\n<p>Postman provides another tab called <em>Tests<\/em>. It is available on the right side of the <em>Body<\/em> tab. You must add the following content to it:<\/p>\n<pre class=\"lang:c# theme:vs2012\">pm.test(\"Registration was successful\", function () {\r\n\tpm.response.to.have.status(201);\r\n    \r\n\tvar jsonData = pm.response.json();\r\n\tpm.expect(jsonData).to.have.property('name');\r\n\tpm.expect(jsonData).to.have.property('email');\r\n\tpm.expect(jsonData).to.have.property('document');\r\n\tpm.expect(jsonData).to.have.property('phone');\r\n\tpm.globals.set(\"user_id\", jsonData.id);\r\n});<\/pre>\n<p>This code simply creates a <a href=\"https:\/\/learning.postman.com\/docs\/writing-scripts\/test-scripts\/\">test script<\/a>. Postman test scripts are implemented in JavaScript and allow you to ensure your API is working as expected by checking stuff like the HTTP response status, headers, and response body content.<\/p>\n<p>The pm object stands for the Postman global object. There, you may find a handful of utility objects and methods such as the <code>pm.response<\/code> (corresponding to the HTTP response), <code>pm.globals<\/code> (the global env variables object), and the <code>pm.expect<\/code> (Postman assert method).<\/p>\n<p>The syntax is very declarative, which makes for easy readability. The example above checks if the HTTP status is 201 (<em>Created<\/em>), if the JSON response has each of the desired properties, and, finally, adding the <code>user_id<\/code> to the env variables so that it can be accessed on the next request.<\/p>\n<p>Speaking of it, the next request of the suite will have the following configs:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1542\" height=\"966\" class=\"wp-image-90838\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-23.png\" \/><\/p>\n<p><strong>Figure 24.<\/strong> <strong>Setting up tests for the second suite request<\/strong><\/p>\n<p>Yes, the second request will make use of the <code>user_id<\/code> on the URL, which was set by the previous one. This way, you guarantee that it&#8217;s always retrieving the recently created user.<\/p>\n<p>Great, now, how to run the suite? It\u2019s simple. Get back to the suite folder and locate the <em>Run<\/em> button as shown in Figure 25.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1264\" height=\"686\" class=\"wp-image-90839\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-24.png\" \/><\/p>\n<p><strong>Figure 25.<\/strong> <strong>Locating the Run button<\/strong><\/p>\n<p>When you click that button, it\u2019ll open a new tab with the suite configs. Leave all the options as they are, except for the <em>Save responses<\/em> checkbox. Make sure to check it to allow Postman to log the responses.<\/p>\n<p>Then, click the <em>Run Test Suites<\/em> button and wait until the tests finish. You may see the following screen as a result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-90840\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2021\/05\/word-image-25.png\" alt=\"Documenting and testing APIs  with Postman\" width=\"2048\" height=\"1296\" \/><\/p>\n<p><strong>Figure 26.<\/strong> <strong>Test suite results<\/strong><\/p>\n<p>The most important information on that screen is related to the success of the execution. If everything\u2019s in green with a <em>Pass<\/em> label, then everything went as expected.<\/p>\n<p>On the right side of the window, you can see the HTTP status of each request, how fast they are executed, and their respective payload sizes.<\/p>\n<p>If you click each endpoint, a floating tab will show up with more granular information about the request and response, such as their headers and body data. That\u2019s a great resource you can use to verify if the test worked as you planned. If an unexpected error happens, this is the right place to investigate it too.<\/p>\n<h2>Documenting and testing APIs with Postman<\/h2>\n<p>So, what did you think? Many developers don\u2019t know about all the possibilities Postman offers for free: powerful and safer APIs that can be documented and tested as you go with your code.<\/p>\n<p>Not only the devs, but also QAs, customer support, and other areas of the company can benefit from it. How about you? How was your experience using Postman? Let me know in the comments!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Postman can be used to automate API tests. In this article, Julio Sampaio demonstrates documenting and testing APIs  with Postman.&hellip;<\/p>\n","protected":false},"author":323407,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143538],"tags":[143551,143550,5134],"coauthors":[93894],"class_list":["post-90814","post","type-post","status-publish","format-standard","hentry","category-dotnet-development","tag-automate-testing","tag-postman","tag-sql-prompt"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/90814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/323407"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=90814"}],"version-history":[{"count":5,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/90814\/revisions"}],"predecessor-version":[{"id":90845,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/90814\/revisions\/90845"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=90814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=90814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=90814"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=90814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}