1 00:00:05,270 --> 00:00:07,830 Now there's some theory with regards to rest. 2 00:00:07,850 --> 00:00:09,530 I'm going to quickly go through it now. 3 00:00:09,890 --> 00:00:11,550 Don't get hung up about the theory. 4 00:00:11,570 --> 00:00:14,090 Jump to the next video if the theory is a bit boring. 5 00:00:14,180 --> 00:00:15,440 You're going to learn more. 6 00:00:15,470 --> 00:00:18,170 If I show you the stuff practically I've given you. 7 00:00:18,170 --> 00:00:20,960 This PowerPoint slide contains some useful information. 8 00:00:20,960 --> 00:00:26,780 So download that if you want to for reading later or for studying, but you're going to learn much more 9 00:00:26,780 --> 00:00:30,230 if you just do it, don't read about it. 10 00:00:30,320 --> 00:00:32,390 If you do it, practically the stuff will make sense. 11 00:00:33,030 --> 00:00:35,340 So if you find this boring, please go to the next video. 12 00:00:35,460 --> 00:00:36,270 Do it practically. 13 00:00:36,270 --> 00:00:38,070 And then you can come back to the theory. 14 00:00:41,500 --> 00:00:43,780 Now the first question is what is rest? 15 00:00:43,960 --> 00:00:52,000 And a great place to look for good information is restful API dot net and we're told that rest is a 16 00:00:52,000 --> 00:00:54,700 acronym for representational state transfer. 17 00:00:55,060 --> 00:01:02,680 It's an architectural style for distributed hyper media systems that was first presented by Roy Fielding 18 00:01:02,680 --> 00:01:05,400 in 2000 in his famous dissertation. 19 00:01:05,410 --> 00:01:11,650 And they've got a link to his dissertation and you can read this whole dissertation to get an idea of 20 00:01:11,650 --> 00:01:12,700 what it's about. 21 00:01:12,730 --> 00:01:17,110 He talks about the fact that it's client server, that it's stateless. 22 00:01:18,310 --> 00:01:22,660 Caching you supported and a whole bunch of other detailed information. 23 00:01:22,660 --> 00:01:25,060 So if you really want to get into it, you can have a look at this. 24 00:01:25,060 --> 00:01:26,760 But let's just summarize it. 25 00:01:26,770 --> 00:01:31,720 I want to go through this fairly quickly and actually show you practically how it works because you'll 26 00:01:31,720 --> 00:01:36,520 learn a lot more if you see it practically rather than just looking at some theory. 27 00:01:37,490 --> 00:01:39,000 First thing is its client server. 28 00:01:39,020 --> 00:01:42,830 By separating the user interface concerns from the data storage concerns. 29 00:01:42,980 --> 00:01:48,020 We improve the portability of the user interface across multiple platforms. 30 00:01:48,710 --> 00:01:51,000 It's basically a client talking to a server. 31 00:01:51,020 --> 00:01:54,260 So I've got a PC talking to a server. 32 00:01:54,290 --> 00:01:58,430 Client server model similar to what we do with HTTP. 33 00:01:58,580 --> 00:02:02,000 I want to go to facebook.com or some kind of web server. 34 00:02:02,090 --> 00:02:07,040 I've got a client running on my computer here, Mac, and I'm connecting to the server. 35 00:02:07,070 --> 00:02:13,640 I send a get I get back a bunch of information that's then displayed on my web browser interface. 36 00:02:14,670 --> 00:02:15,900 It's stateless. 37 00:02:16,590 --> 00:02:22,710 Each request from client to server must contain all the information necessary to understand the request, 38 00:02:22,710 --> 00:02:27,090 and it cannot take advantage of stored context on the server. 39 00:02:27,210 --> 00:02:31,200 Session state is therefore entirely kept on the client. 40 00:02:31,620 --> 00:02:38,580 That's very different to soap, which was an older way of implementing APIs in an enterprise. 41 00:02:38,820 --> 00:02:42,190 In that example, state information is maintained on the server. 42 00:02:42,210 --> 00:02:44,960 Here we don't maintain state on the server. 43 00:02:44,970 --> 00:02:47,340 Everything needs to be maintained on the client. 44 00:02:47,610 --> 00:02:54,240 Its also catchable cache constraints require that data within a response to a request be implicitly 45 00:02:54,240 --> 00:02:57,810 or explicitly labeled as catchable or non catchable. 46 00:02:57,990 --> 00:03:04,200 If a response is catchable, then a client cache is given the right to reuse that response data for 47 00:03:04,200 --> 00:03:06,120 later equivalent requests. 48 00:03:06,480 --> 00:03:10,580 You may have come across caching on your web browser many, many times. 49 00:03:10,590 --> 00:03:12,840 Data is cached by web browsers. 50 00:03:12,930 --> 00:03:13,900 Happens a lot. 51 00:03:13,920 --> 00:03:20,970 If I want to force a page to refresh as an example, I have to press control or on a mac. 52 00:03:21,570 --> 00:03:28,680 You sometimes have to re force a refresh of the page because stale information will be stored on your 53 00:03:28,680 --> 00:03:29,640 local computer. 54 00:03:29,650 --> 00:03:33,060 So something could be changed on the server, but you don't see the changes on your PC. 55 00:03:33,090 --> 00:03:39,720 So on Windows and other browsers, you have to press control F5 to refresh the page and force a download 56 00:03:39,720 --> 00:03:45,240 of all the elements such as the pictures and other information, rather than using a locally stored 57 00:03:45,240 --> 00:03:47,100 cache of some of the information. 58 00:03:47,280 --> 00:03:50,610 So we might not want everything stored in cache. 59 00:03:50,790 --> 00:03:57,960 So rest API as an example and web servers will allow information to be cached on the local client rather 60 00:03:57,960 --> 00:03:59,880 than pulling everything from the server. 61 00:03:59,880 --> 00:04:03,210 Every time I go to a web page or make an API call. 62 00:04:04,380 --> 00:04:04,620 Okay. 63 00:04:04,620 --> 00:04:08,010 So that's enough about the principals have a read of this if you're interested. 64 00:04:08,310 --> 00:04:13,260 They also talk about a resource key obstruction of information and rest is a resource. 65 00:04:13,530 --> 00:04:20,399 Any information that can be named can be a resource which could be a document, an image, a service, 66 00:04:20,399 --> 00:04:22,920 a collection of resources, etc., etc.. 67 00:04:23,310 --> 00:04:27,660 So I would suggest you have a quick read of some of this, but you're going to learn a lot more if I 68 00:04:27,660 --> 00:04:28,920 just demonstrate this practically. 69 00:04:28,920 --> 00:04:30,030 So that's what I'm going to do. 70 00:04:31,120 --> 00:04:37,420 Now something else you'll come across is crud, which in computer programming means create, read, 71 00:04:37,420 --> 00:04:42,520 update and delete and are for basic functions of persistent storage. 72 00:04:42,940 --> 00:04:45,340 These are four actions performed by an application. 73 00:04:45,340 --> 00:04:48,100 We could create something on a server. 74 00:04:48,130 --> 00:04:50,770 We could read data from the server. 75 00:04:50,770 --> 00:04:56,590 We could update something on the server, and we can delete information on the server. 76 00:04:57,010 --> 00:05:03,370 Now I'm going to demonstrate the use of Postman in a moment, but notice here we've got get yeah, we've 77 00:05:03,370 --> 00:05:11,950 got post, we've got delete, we've got patch, we've got other what are known as HTTP verbs. 78 00:05:12,100 --> 00:05:16,450 So Post will allow me to create new data structures and variables. 79 00:05:16,450 --> 00:05:25,810 That's the C in crud for create get allows me to read or retrieve a variable name structures and values 80 00:05:26,320 --> 00:05:33,010 patch and put allow me to update or replace a values of some verbal and delete. 81 00:05:33,010 --> 00:05:37,390 Fairly easy to understand allows me to delete variables and data structures. 82 00:05:38,210 --> 00:05:45,080 Now postman and application are we going to use in a moment has those HTTP verbs, but it's not going 83 00:05:45,080 --> 00:05:48,170 to mean much to you just by reading about this stuff. 84 00:05:48,170 --> 00:05:49,880 It means a lot more if we just do it. 85 00:05:49,880 --> 00:05:52,250 So I'm going to just show you practically how to do it.