1 00:00:00,290 --> 00:00:04,660 When developing an API, it's helpful to have a way to test without having to 2 00:00:04,660 --> 00:00:08,140 use a client application that consumes your API. 3 00:00:08,140 --> 00:00:12,280 Let's see how we can use a tool called Postman to interactively test our API. 4 00:00:13,600 --> 00:00:19,360 Postman is a native application available for MAC OS, Windows, and Linux. 5 00:00:19,360 --> 00:00:22,001 For instructions on how to download and 6 00:00:22,001 --> 00:00:25,850 install Postman see their website, getpostman.com. 7 00:00:25,850 --> 00:00:28,730 I already have Postman installed on my machine. 8 00:00:28,730 --> 00:00:33,080 To make a get request, you enter a URL and click the send button. 9 00:00:34,330 --> 00:00:37,360 But first, let's start our application in Visual Studio. 10 00:00:38,930 --> 00:00:43,287 Set break points in both the get action methods and start the application. 11 00:00:57,896 --> 00:01:03,134 Once the application has started, make note of the port number in the URL, 12 00:01:03,134 --> 00:01:07,065 or simply select the URL, and copy it to the clipboard. 13 00:01:07,065 --> 00:01:10,685 Visual Studio randomly sets this number for your project, so 14 00:01:10,685 --> 00:01:13,975 your port number will most likely be different than the one you see here. 15 00:01:15,912 --> 00:01:21,720 In Postman, for the request URL enter http://localhost 16 00:01:21,720 --> 00:01:25,510 followed by the port number for your application. 17 00:01:25,510 --> 00:01:30,790 Or if you copied the URL to the clipboard like I did, simply paste the URL 18 00:01:30,790 --> 00:01:35,080 into this field and remove the pound sign slash entries. 19 00:01:36,440 --> 00:01:40,625 Then after the port number enter, 20 00:01:40,625 --> 00:01:45,682 api/entries and click the send button. 21 00:01:48,832 --> 00:01:53,990 Here we are in Visual Studio at our break point in our first get action method. 22 00:01:53,990 --> 00:01:58,150 Press F5 to continue execution and switch back to Postman. 23 00:01:58,150 --> 00:02:01,816 And here's the response data formatted as JSON displayed 24 00:02:01,816 --> 00:02:04,446 in the bottom section of the current tab. 25 00:02:06,021 --> 00:02:09,610 Now let's try retrieving a single entry resource. 26 00:02:09,610 --> 00:02:14,343 To do that, just add a 1 after the /API/entries path and 27 00:02:14,343 --> 00:02:16,284 click the Send button. 28 00:02:19,231 --> 00:02:21,898 And here we are in Visual Studio again. 29 00:02:21,898 --> 00:02:26,500 This time we're at our break point in the second get action method. 30 00:02:26,500 --> 00:02:29,800 Press F5 to continue execution and switch back to Postman. 31 00:02:30,840 --> 00:02:33,420 We aren't returning any data from our method, so 32 00:02:33,420 --> 00:02:36,660 there isn't any data to display here in Postman. 33 00:02:36,660 --> 00:02:40,560 We'll finish implementing our get methods in the next session. 34 00:02:40,560 --> 00:02:45,120 Later in this section, we'll see how to make requests that contain a message body, 35 00:02:45,120 --> 00:02:48,590 for example, a post request to create a resource. 36 00:02:48,590 --> 00:02:49,650 Here on the left, 37 00:02:49,650 --> 00:02:54,240 under the History section, we can see a history of the requests that we've made. 38 00:02:54,240 --> 00:02:57,660 Here's our first and second get requests. 39 00:02:57,660 --> 00:02:59,676 We can click on the first get request and 40 00:02:59,676 --> 00:03:03,171 click the send button to make the request against the server again. 41 00:03:06,546 --> 00:03:11,450 We'll continue to use Postman to test our API throughout the rest of the course. 42 00:03:11,450 --> 00:03:15,300 We're just scratching the surface of what Postman is capable of doing. 43 00:03:15,300 --> 00:03:18,650 See the teacher's notes for more information about Postman. 44 00:03:18,650 --> 00:03:22,270 Looking at the response data for our first get request again, 45 00:03:22,270 --> 00:03:27,375 how did the data that we returned from our controller action method get converted, or 46 00:03:27,375 --> 00:03:30,080 serialized, to JSON formatted data? 47 00:03:31,230 --> 00:03:35,990 Coming up next, we'll take a look at a feature called content negotiation and 48 00:03:35,990 --> 00:03:39,220 learn how Web API serializes our data. 49 00:03:39,220 --> 00:03:39,750 See you then.