Postman API tutorial for beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there my name is Valentine and in this video I wanted to introduce you to a great web development and testing tool for working with api's it is called postman and it's available for Windows Mac OS and Linux and just in case you have a chrome plugin called postman still installed in your browser make sure you remove that and install the standalone application as the browser plug-in is no longer supported and updated in this tutorial I want you to show you how you can get started with postman by using the real world REST API postman is an easy-to-use tool and ideal if you're writing your own API so if you're writing server-side code in a technology like PHP or Java or nodejs or whatever you're using out there and you come to a point where you have something ready and you would like to see how it's working with postman you can immediately start interacting with your back-end and get some feedback on how things are going if the API is working the way you expect it to you can test different parameters different authentication methods setting headers cookies whatever application needs to all this without building client-side all this without writing any front-end code and this cannot only speed a developer time but the experience shows that it's much easier to find bugs early in the development stage now you don't have to build your own API to take advantage of postman imagine that you want to use the third party API in your application let's say for example Facebook or Google's API or whatever API is out there and with postman you can get a feeling on how that API is performing you can easily check on what the information that's available how you can interact with it and you can do all this without writing a single line of code and this is quite powerful because again it really improves the development time and you know in advance that the API is working in a certain way and there will be no big surprises when you actually start using it now it really doesn't matter how you plan to use postman as long as the API you are playing to use is an HTTP based restful api so if you're excited about learning postman keep watching this video and I will through it once you open the application it will probably look like this so with postman you can create an account and everything you do inside postman will be saved and synchronized with the postman servers so it's a great way not to lose your work you don't have to do it in the beginning you can just click take me straight to the app it's right here below a bit a bit grayed out and just in case you want later to use that functionality here in the corner you will see here this is sign-in button and once you click it you will have the possibility of signing up for an account now the next time we'll open the application it will look like this and postman is actually divided in different sections and I want you to go through them the most important one and probably the first one where you will start is this section and this is called the request builder and it's called a request builder because it actually offers you all the information that you need in order to build a request once you have a request and you click the send button the request will be sent and you will see here below a response and we'll look into that a bit later once you have a couple of requests you will able to see here on the Left panel a history you will see a list of all the requests you previously sent and you have the possibility of going back in history just as with a normal browser and resend a specific request all around the interface you will find other shortcuts as well but we will deal with them in another video I wanted to demystify postman right from the beginning and just point out that postman is nothing more than a browser but which exposes a lot more functionality that a normal browser usually will not show you so the thing with people smell is that you can't create a specific HTTP request with a request builder this section here and you have full control by setting the request method address any headers that you need and the body as you need them to you'll also notice that you have the possibility of using multiple tabs and closing them so the first thing would be to just type in google.com it's a send button and see what happens now as you can see in the section below where the response is you will have actually the response from the Google server and you will see here that the first step is already selected and this is the body so this is basically what you normally see in a browser if you call google.com now so this is actually showing the HTML code when running google.com but if I click this preview button I would be able to see a much nicer version of that website now this doesn't really help us a lot but it gets you an understanding on how postman actually works and what's the functionality usually will not use postman for interacting with Google or any other web site like Facebook something like that but you will use more specific address where they exposing an API in a much nicer format but still since we're at Google that come let's play a bit and actually do a query and we're going to do that query by actually using postman so if I change the address here to search I'll be able to add a query parameter and let's search for postman I submit this again and now I should get a results page with postman still this is not very exciting but what happens a lot is a lot of resources are being generated by using query parameters and as you can see here the query parameters in this case is U and it equals to postman and the first nice feature that you can use in postman is actually this button here params and once you click it you will see a much nicer interface for adding parameters let's imagine that we have another parameter called anger I don't even know if this exists but let's say Lange US or something like that and as soon as I have typed it you will see here that the address above has changed so the end has been added to the address and now it's and now it reads Lang equals u.s. and if I submit this this exact elders will go to Google at the same time I have the possibility of editing previous values and you will quickly see the value of this if you have here a long address with a lot of parameters using this panel you can add other parameters you can change the values and you can also disable them so everywhere in postman you will see this check box once you tick it you will see that the parameter will disappear and it will not longer be added to the address and once you need it back you can just edit it back again the same goes with this bulk editing functionality you'll see it in postman all over all over the place for different things and if you click this you will see this probably not so nice interface anymore but this allows you for example to select everything to copy it to switch back to the previous mode go to a new request open the parents open the bulk edit functionality pasting it and you will have the same parameters you had in the previous request it's a nice way to copy things around if you needed to now this length parameter is something that I really don't need so I'll just delete it and actually the query that the way I have it looks pretty good so I'm just gonna click on save and I can save actually this request for later use and in order to do that I first need to create a collection I'll just call it Google and inside that collection I will save this now the default request name is actually the address that you have called what I can just give it our name so I named it pores postman search I'll save it to the Google collection and once you do that they you will see here on the left side they are two panels one is the history which shows all the addresses that have been used and the second one is collections and this gives information on different collections and one of this collection is Google and even if I close this tab here we'll still be able to see this request inside a collection and I'll be able to resend it over and over again as often as I need and it will not get lost I hope you enjoyed this video and if so please give it a thumbs up and make sure you subscribe to this channel for more news and updates on postman if you want to learn more about postman and use it at its full potential I invite you to check out my online course on postman I have tried to structure everything you need to know about postman in an easy-to-follow online course there I'll take you from learning how to use postman for creating requests to writing tests using variables dealing with authentication and eventually towards using postman as a solution to fully automate your REST API testing process by using tools such as Neumann Jenkins and any other continuous integration tools during the entire course I will keep you engaged with quizzes and assignments and provide your personal feedback on how you're doing make sure you check this video description for a link and I'm totally looking forward to seeing you inside now Google hasn't been so excited to use so far so for that reason let's move on to something more exciting and I'm currently at asana comm which is like a project task management software you can register for a free account here and the idea would be to register for a free account and get access to their API so that you can create a task inside the workspace and this will be the interface now in order to interact with a sauna API we need to get a token way to get an authorization token usually how the api's work is that they don't ask for your username and password but a generation sign card of token or they redirect you to a different website where you can login yourself and then came back to that application and in this case is pretty similar so from here I'm gonna go to my profile settings go to the apps tab and I click on manage developer apps in hereafter possibility of creating a personal access token and this is a Texas token that grants access to my account and it's the quickest way on how you can use this particular API I'll say the token is for postman yesterday later remember for what I could eat it let's just copy to the clipboard and go back to postman now I'm gonna close the tab that I previously created and I'm gonna type an address and that's the address of the API okay so wondering how do I know that I have read the developer documentation on how to use the API and this is why I already know the API in advance this is what you will normally do you would read first the API to see how to interact with it the first thing that we'll try to do is to get the workspaces associated to my account and let's see what happens generally if I just submit this request and you will see here because I'm interacting with an API the format of the response has changed so what you see here is JSON and this is the pretty version and you can switch in between different ones of this bra response which doesn't look so nice is actually the pretty version and just in case it gets a bit larger you have to here the possibility of collapse in it and making it smaller and what's basically telling me is that I'm not authorized so token that I just generated and need to provide it to the application with making that request and in the case of this application this is done by using a header so if I'm switching here at a request builder and in the headers tab I'll be able to add an authorization header and as soon as I start typing you will see here some other completion happening and I will select authorization and the value will be bearer and then I'm gonna paste in coconut I just add if I resubmit this request again we'll see that it looks a bit different so not only this request succeeded and you will see here the status code it's 200 its success let's just remove the authorization for a second this was a 401 unauthorized a task so it's a good sign and actually I'm getting the information that's relevant for my account so this is my account this is the workspace that I basically have available now what I wanted originally to do is create a simple tasks inside this project and the API works in a way that you first need to know your workspace ID in order to create a task inside that workspace next what I'm going to do is I'm going to copy the same address and I'm gonna open a different tab that is this address again and from the previous response I will take this value just simply added after workspaces then tasks because I'm trying to create a tasks the HTTP method that's required for achieving that is actually the post method so from this list of a lot of values I will select the second one post and as soon as I have done that another tab is no longer grayed out and that is the body and at the body you can actually send data and if you imagine a normal website every time you submit a form you most likely do a post request to the backend server and this is exactly what I'm trying to do and in this case the resource that we are going to create is a new tasks so let's simply gave for that task a name and as you can see here I'm in form data I'm going to enter a new key and this is given by the API so if I want to create a name for the tasks I need to provide a key name first thoughts that I have now again if I simply submit this request it will not automatically work because I am missing the authentication so I'm gonna switch back to this tab just gonna go in the bulk edit mode copy this value which back here go to the headers all cat it is this again and now if I send my task will be created so see here 201 the status code and if I go back to asana calm you will see here on all items that I have created my first task another thing I wanted to show is this address so in the example with Google we had this query parameters but in essence this workspace ID is still sort of like a parameter that can change so we're gonna click the parents option again and just gonna copy that and instead of that I'm gonna type a workspace ID with a column in front of it and as soon I start with typing it with column in front we'll see that's available in this panel with parents and once I do this I can paste the project ID value here and once the request will be run this will be automatically be replaced by postman so it's a nice way to add values here and to be able much easily to change them later in case you need that and just demonstrated that this is actually working I submitted and this work as well so the second task appeared let's recap for a bit but you can do with postman is you can select your HTTP method get post put delete whatever you need mostly you will use get and post and put and delete probably once you select a method like post you will have access to a body and in this case we just used form data but a lot of api's actually require you you send them data in a JSON format and in case you need to do that and this is not supported by the Sun API but I just wanted to show you how it will look like you're gonna click this raw radio button and from here you can just select application Jason and once you have that you can just start writing Jason so for example exactly what's coming here below as a response this is how you can create your request as well so it doesn't have to be exactly this request but this is where you will put your jason same as i did by google i can simply save this request and let's call this workspaces Oh No another nice feature we can take advantage of is variables now postman there are a lot of variables that you can use and I just wanted to show you one of them and it's called collection variables and it usually makes sense to put in a variable things that may later change and for example the X in Stoke and the person access token we got it's maybe something you would like to revoke at a certain period or maybe it's not valid anymore and you have a lot of requests it does make a lot of sense not to reuse it all over the place but to just store it once in a variable and just use the variable where this is needed so let me quickly inspect a header I'm gonna copy this value and only the token it ahead and if I click the collection I will see here an edit button and right here at the end there's this variable tab call this a Sun token it's the value and now the request builder if I need to actually access the access token I can do that and for that matter I can do that for any variable and to do that I'm gonna use curly brackets so double curly brackets and this is your variable and the same goes for creating a task don't list it and type you so this is really the syntax on how you'll use that word that it works if I said if I hit a send button it will work just as previously as it's a nice way on how you can organize things and to be sure that you're not repeating yourself last but not least another important feature you should know about impulse man is the console and this is hidden right here at the bottom and if you click this button another window will open and in this window postman will lock any request that you said so let me exemplify this if I submit a request the same button but I want to make sure I want to inspect exactly what happened with our request I can switch the postman console and you will see here that the first request is this get request and I have the possibility of really looking into what are the request headers what have I sent for example you will see here at the authorization is exactly the token that I used as a variable and addition you will be able to see what came back from the server this is the response body from the sir it provides a more technical overview of the information most of the information would see in postman as well but in case something is not working or for example these variables are not working as you expect them to work it's a nice way on how you can inspect or exactly what is going not only come to an end of this introduction to postman here some ideas on what you can do next with postman our in the request builder you will see that there are two more available tabs one of them is this pre quest script and the other one is this test in the pre-crash script you can write custom JavaScript code that is executed before the request happens and in combination with variables it allows you to control certain aspects and values of the request going out and to really be able to create complex scenarios and workflows in the test tab you can write your own tests which allows you to check that the API is returning the same status code and body every time you run the request so postman can help you even more to make sure that there are no regressions in your code and a simple example would be going to the tests right here on the right you will see some snippets and one of the snippets that it's quite easy and to use is the status code is 200 and I'm not going to go exactly into what happens but the next time we'll hit the send button you'll be able to see here that a tap the tap test results has changed and now you have a test that it's passing so in case something is not right with this request for example if I remove the outer ization header and submit the button again well actually this test will be marked as failed because you expected the request to be r200 but you got a 401 so let me quickly show you an OVA of your postman now with postman you can really go in different ways so what I've showed you so far is how to do manual API testing so basically how to explore an API and I quickly touched the part with scripts and that you can create workflows and that you can create tests and once you have some work clothes and some tests you can really go into direction of automatic API testing and automatic API testing basically means that you have a collection of requests that are running in a particular order each request is testing something so at a mini-mall you test at the status code is whatever that scenario specifies it it should be and you will run this collection of requests over and over again without any manual integration and there are a lot of tools to help you with that one of them is the postman monitors which is hosted at postman and sort of calls your collection every time from their servers and sees that it's still working properly as you expect them to and with a tool like Neumann you can actually go in the direction of automation by integrating with Jenkins as a continuous integration server or with any other integration server that your organization might be using and this is direction of automatic API testing as I said the other direction was of the manual test but there are other things that postman can help you with so with postman you can really document your API API and create some example requests and some example responses and really generate some HTML documentation that somebody can look at and easily import the postman collection and see how it's going if you're working in a team probably collaboration is a big thing and with this account and with the pro version you can really integrate postman in your team so that you have multiple people working on the same collections and instantly sharing the changes that they're working on and additionally what postman can do as well among other things that are not on this slide is to provide your mock server in case you're having an external system that you depend upon but you want to just to improve your testing infrastructure you can just Bach adores the request and postman can help you with stuff like that as well now I hope this introduction to postman was helpful to you thank you for watching this introduction to postman and hopefully this is just enough to get you started if you have any feedback or questions make sure you post them in the comment section I hope you enjoyed this video and if so please give it a thumbs up and make sure you subscribe to this channel for more news and updates on postman if you want to learn more about postman and use it at its full potential I invite you to check out my online course on postman I have tried to structure everything you need to know about postman in an easy-to-follow online course there I'll take you from learning how to use postman for creating requests to writing tests using variables dealing with authentication and eventually to words using postman as a solution to fully automate your REST API testing process by using tools such as Neumann Jenkins and any other continuous integration tools during the entire course I will keep you engaged with quizzes and assignment and provide your personal feedback on how you're doing make sure you check this video description for a link and I'm totally looking forward to seeing you inside
Info
Channel: Valentin Despa
Views: 285,832
Rating: 4.9059758 out of 5
Keywords: postman, rest-api, postman-api, postmen, restul-api, post-request, http-post, post-request-postman
Id: FjgYtQK_zLE
Channel Id: undefined
Length: 27min 14sec (1634 seconds)
Published: Wed Jan 31 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.