API | UiPath Automation API | HTTP Request | HTTP Response | API Call in UIPath

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys myself rakesh and welcome back to my channel in the previous part of api in ui path series right we have in the api integration series we have learned what is an api right just to recap you know we'll have a quick recap so we have seen how uh you know what is an api and how that works in the background so in the previous video i have explained from your laptop when you type an url the url is converted to a http request you from the browser the browser will do the job and then the browser is creating a http request having a header having a right having a body so all this we have learnt in the previous video and then it goes to the server and from the server once the http request this is the main keyword you should remember you know from from a client machine from the laptop machine i mean from the laptop the request has been sent to the server which is known as the http request and from the server the data will come back to our laptop which is known as http response right so these are the two different keywords we have learned and entire mechanism what you see right all this happens through the api the api does the task of sending you know sending the data from the laptop browser to the server and fetching the data from the server to back to the laptop wherein i finally see the facebook page right this is what we have learnt so i talked about status code in the http response i spoke about the url and the verb dot get so how do i really implement in the ui path we are going to learn it okay so remember this two keywords http request http response status code write get verb so what are all this and how do you really implement that on ui path we are going to learn so let's get back to uipath studio now first of all um you know to do a http request so what is the job of this http request anything any data that i would like to get from the server through the api call right i can request the data from the server and get the output here in this example it was a simple example of facebook.com just to have an understanding what the api call looks like but again in practical scenarios you don't open a page or something like that you require some data from the page right you require some data for the page for example if i ask you hey you need to collect the weather data what is the current temperature of the city what is the maximum humidity maximum temperature minimum temperature for that what you do you generally go to a website and then try to fetch the data so in this example to understand api uh and how do you do a api call from uipath first of all what you do you log into a website called open weather okay so there are multiple such public endpoints uh for api request so go to this openweather.org okay we'll do step by step so what you do first of all on your browser type open weather and go to this specific page okay there is a weather api so just click on it okay all right so you have got a lot many things you don't have to worry about it all you do here on the browser i am going to provide the link in the description all you do just type current okay just type current and hit on enter got it so type current here this is the url i will provide this url on the description of the video so once you do this you will be landed to this specific page so this page has got a lot many things okay so you will be completely confused uh which one to use right so what you do once you are there on the page on the right hand side there is something called built-in api request by city name look at this built-in api request by city name so this is what you need to click okay so once you click see again don't scroll up or scroll down you'll be confused this this is a hyperlink just it'll take you to the the entire page having a lot many things okay so the moment i hit on city name it will just you know bring it down and show you the required api endpoint link that you need for this exercise okay so once you are there on this page what is the next thing i should do now go back to the uipath studio the very first thing you do go to the manage packages okay and then go to official and type uipath web api the moment you type search here uipath web api uipath dot web api okay so the moment you type this it will automatically show you if not hit on the official okay i did not type the spelling properly uipath.web okay so uh web api activities this is the one you need to install and save okay so once you do that what you find so i spoke about two important things right the http request and http response the same activities available the once the package is installed if you type http right you find the http request all you do drag and drop this http request so what i am trying to do the moment you drag and drop this box will come so what i am trying to exactly do in this current weather data right using this api i can fetch any city in the world what is the current temperature what is the minimum temperature for the day what are the maximum lot many details around the weather okay so i will be able to fetch the data rather than generally if i ask you to fetch some data you go to that website and then you scrape the data you copy the data you do the scraping you do the get text and try to get the data you know you know you write a workflow for that to scrape the data from the website rather than scraping the data what if i have a api using this api endpoint i can directly fetch the data to my ui path studio and then whatever i would like to do with the data i can do it so this is more convenient rather than doing a data scraping right so rather than doing a data scraping this would be more convenient so what is this let's learn okay so once you open this so what i did till now all i did is drag and drop this http request okay let me enlarge the screen little more so that will be visible to all okay now in this one what i will do hit on the configure button okay now it is asking you to provide the end point end point what is this endpoint is all about the every api call so every site will have their own uh this kind of a page where they will mention the api link and all that so every site will have different thing now for a learner this would be a site where you can practice you know you can give it you know try to learn so here what i'm doing i'm going to copy the endpoint url okay so copy until the question mark okay let me enlarge this slide a bit so what i am doing i am copying it till the question mark not the queue these are the parameters so i am not copying any parameter just until here i copied it okay so ensure you are in the city name okay only when you click on the city name this you will see otherwise there are different procedures you will be confused on the top there will be different ones okay so don't be confused so if you see you scroll up there will be multiple uh api where you will be confused for example this one is a different format latitude longitude so always click on the city name and from here you should start so i'm going to copy this okay copy this go back and in the end point i'm going to paste it getting it so i pasted the end point the moment you do this the preview url will automatically populate this much is clear what we have done okay and why are we doing this rather than doing a data scrape and trying to paste the weather data you know temperature humidity and all that we are going to do this through the api through the api i will directly send a request to the server and from the server i will collect the data right so how that works we we're going to see just in few minutes okay so this much is done after that you don't have to really do anything over here all you do there is something called request method so what we are doing we are doing a http request and in the request method i spoke about get right there are multiple such methods get post put delete head options patch merge there are lot many options so here i am going to use the get there is also an option called trace it is not here in uipath but again there are multiple options so here the request method i am saying get so in the previous video i taught you right when i am doing http request i am doing get the verb i am using get this is the method the same thing i am trying to use it here simply i am saying get request method i have selected get so this much is clear very good now nothing to do here there is also something called accept response ads so any json xml custom how do you want to you know get the data so you don't have to worry about it because if you read the uh you know instructions here by default this data is collected as json in this in this specific website the data is collected as json by default if not you have an option even in the ui path to define which way you want okay so leave it as it is and now let's click on the parameters so once you learn this example then you can do lot of experiment first goal is to let's do it in the normal way and understand how it is working then we can try to navigate and do other try to explore other options okay now this much is done now i am going to add parameters so what are these parameters when i am doing a api call the api call require few important things for example uh city name here the city name is imported rank so this becomes the input so you wanted to fetch the data for a city let's say london i want to fetch the data for london i want to fetch the data for delhi so the city name has to be provided so the api understands hey this guy who is requesting data he only needs data for this specific city name right because i am using the api key based on the city name so he needs the data only for the city name so this this parameters are required where i am going to pass the value so to pass the value what you do here the parameter code is written so i will copy the code so it will be different for different websites so here it is queue or different api calls it will be different so it will you should always go through the documentation of that specific site or if you do not have a documentation you should request from the it support of that specific site to give you api calls if they are available generally it will be chargeable all right it will be there will be charge but again for practice purpose we'll just use a free site just to see how these things are working so i'm going to copy this okay and here what i'm going to do i'm going to click on add parameter okay add parameter and i'm going to copy paste the parameter simple this much is understood so i'm copying the parameter and the value i will pass without any double quotes a single quote simply write london let's say okay i'm citing so go with this example then you will change the city name i will also change the city name later let's go with this example london okay while you are practicing just follow how i am doing so once you get the output then try to make changes and see how things are working okay so this is understood now next thing so here what is saying these things are required so couple of parameters are required you can't skip them so q we have provided next thing it is required is your unique api key you need a api key for this so what i will do i'll first copy the parameter name which is i'll hit on add parameter and copy paste the app id now what is this app id you need a key to access this server right you can't just access just like that you need a key like to access even facebook you need a password that is your key so without a key you can't access something right generally on a if generally the site will ask you hey provide your authentication key that's where i would give you the data so here to get the key what you do hit on the api key tab okay hit on the api key tab now this will ask you to sign in if you have not created an account hit on create an account okay create an account provide a username whatever you want your enter enter your email address your password repeat password and accept all these agreements that are there right and then i'm not a robot and create an account so i have already done that okay i've already done that so i'll move back so here i'm going to sign in so once i sign in what i did i hit on the api key tag that brought to this page where it is asking me to sign in if it is for the very first time if you are entering this site please create an account and then sign in so once you sign in it will show you the api key so once you sign in for example right now i got signed in if i hit on the api key tab it will automatically bring that this page where i see the api key so every person will have their own specific keys so you can copy that go back to your studio and here in the api id just paste it do not put any double code single code nothing okay that's it done so once i do this so what i have provided the required parameters i have provided london the name of the city which is the queue code app id this is the key to access the server so it will go and hit this server open weather server from my ui studio and the http request is sent to the server with this parameters and once it authenticates you through the key and it will give you the data back for the london city what is the current weather so you can also so rest of the things i am leaving it as it is okay i'm not touching anything else i'm just leaving as it is that's all so once this is done if you hit on preview the moment you hit on preview this is the response that i have got from the server so what is the response in the response what i have let me copy this entire data to a notepad which will be where it will be easy to see the data properly okay so you can see the entire data i have got whether id is 802 clouds so it is for the london city so the temperature is at 288.11 this is coming in fahrenheit so how to change that to degree celsius i am going to show you a maximum temperature minimum temperature maximum temperature pressure humidity all these values are there time zone and here it is having the city name london code 200 i spoke about code 200 right in the in the previous video i have explained you it will come with the status quo one the http response will come with the uh output uh html so right now we are getting the output in json format json xml html there are multiple formats i can choose so right now i'm choosing this json format so here the status code is 200 means it's okay right it's able to fetch the data okay now uh it's able to fetch the data so what i'm trying to talk is this entire data which you have got this is known as the json format so what is a json format in the json format you would generally find there will be different different things for example whether is a parameter right cloud is a parameter so visibility is a parameter so what happens this this is called a object in json you call is an object and the object will have multiple properties for example if i tell you uh for example i say iphone right iphone 13 let's say i say so iphone 13 has its own unique properties for example price this much specific price size uh weight um and then you know what do you say what is the what is the memory size what is the processor used so every object will have its own specific set of properties similar way in json anything that is there inside a curly braces this entire thing is one object so this is one object whether is an object and within that object i have within this open curly braces and closed curly braces these are the properties these are the properties and these are the values so id is 100 802 main cloud so these are the values same way there is again one object called main and inside this object inside this object once again i have multiple properties let's say temperature is a property and it has a value ah feels like is a property this has a value temperature minimum is a property so this keywords are important okay so this main anything which are there in open and closed braces this entire thing called this one is an object this is the object and these are the properties within the curly braces so what are the properties temperature feels like all these are properties and what are the values of the properties on the right hand side you have the values of the property so this much is clear so you should understand when somebody say json object many people will be confused if they are very new what is the json object so don't worry json object means anything which are in the curly braces the main uh you know here in it will be that you will have a colon and then there will be open curly braces and curly braces so this will become one object similar way if you see um this one so this doesn't have this is a direct object which doesn't have a curly braces direct object so here if you see wind wind again has got two different properties speed and deg and this become wind will be up wind will be a json object similar way cloud would be json object dt will be json object so these are the objects so in a json file you will have multiple objects so this is one object this is one object getting it and these are the object properties and values it should be very clear okay there is an object json object properties and property values getting it so so these are the three different terms if you are well aware then it will not be at all confusing okay this will not be a confusing topic at all okay now let's see couple of more things okay so i have got the data i have got the data this is how the data is coming right this is how the data has come now i was talking about few more things what um what if you know the temperature was coming in which format if you saw this was coming in where is that uh here temperature was coming in fahrenheit so let's say i would like to get in degree celsius again for all such things you should always follow back you should go back to the api page and you should read so here it is saying if you look at the mode by default it will come in json format if you need xml you can use this parameter for example i need xml kind of a data or html kind of a data i'll show one by one okay let me copy this parameter more i'll go back to the studio go to the request builder and in the request builder i will add parameter i'll paste this mode okay and then um i'll go back to the website once again and here it is saying let's say i need html kind of a data so i'll copy this value and i'll go back to the studio that's all you know you read the instructions from the source website and according to the instruction you should do it because they are all defined predefined so if i hit on preview now the data will come in html format you see the data has come in html format getting it okay now um generally json would be more convenient um so i will keep it to json so i will delete this now let's say um this was coming in fahrenheit the temperature was coming in fahrenheit let's say i would like to change that to let's say degree celsius again there is something called units units are measurements standard metric and imperial units are available if you do not use this units parameter standard units will be applied if you are not using the parameter standard by default will be applied now let's say i want degrees so click on that learn more you saw that right what i did hit on the learn more and here you will get an explanation for temperature in fahrenheit use units at units equals to imperial for temperature in celsius use units in metric so i have to use metric so i'll copy this value it's very simple okay it's very easy just that you should have little you know little try it so i need to have add parameter let me paste the value and let me go back to the site and let me copy the parameter name which is units done now if i uh if you just saw the in the preview the value was in fahrenheit so what i will do if i hit on preview now because i have provided a parameter for degree celsius so what would happen the value now has come in degree celsius you can see 14 degree dot six one right all this has changed it to degree celsius so like that you have multiple options for example let me show you a couple of interesting things okay uh that's where you learn so i'll go back so language okay language let's see if it is coming in hindi language or not okay fun so let's hit on add parameter i'm going to hit on you know put the parameter name and then the value so how do i know the value for hindi all you do hit on the learn more then scroll down scroll down down so here you have all the codes okay now for hindi uh here it is h i okay so i have to go back to the studio and simply type it h i done now let's see if the data is coming in hindi or not so hit on preview okay so here you can see kuch badal do you see description so it has come in hindi some of the data the numbers will come in anyways in english uh so here the name is london right it's saying london okay so this is one of the fun tasks to do okay this now let's play with something else okay i'll remove that okay i'll keep it to english so i'll hit select this hit on delete okay now the next thing what we will do uh we will we will try to let me go back to the page main page so here um am i in the main page if not hit on this hyperlink okay um now what i want i want to have i want to enter delhi okay so for delhi how exactly it should be written if you don't know all right um so let's hit on this iso okay this is not required this is not required let's go back to the studio and instead of london let me type delhi you can try with different cities okay delhi um now hit on preview let's see what are the temperature in delhi so what is saying 27 degree temperature minimum temperature for the day is 27.05 okay response status code is 200 that means it is able to fetch the data okay name is delhi so getting it so all these details are coming properly for us okay so this much we have understood how this data is coming uh so i'll hit on okay i'll hit on okay all right so you i spoke about two different things right what is the json object what is that what is the json object so json if i ask you hey this is the json file or not tell me this is json file right start with the curly braces and will end with the curly braces okay so this is a json file which will have objects and within the object there will be object properties and values properties and values so this is an object and within the within the braces this has again object properties and values object properties and values okay so this this thing is understood now let me show you um you know let me show you how how this one exactly so i got the data so the http request the moment i run it will fetch the data so once it fits the data first thing i would like to store it in the output right so there will be something called output here do you see output okay so here is the output now here there are multiple things you will go with the response content so we need the entire content so what i will do i'll create a variable and give it a name called json string why i'm saying json string the data fetched from the server the json format the format will come in the json but again this is you can copy paste into a notepad i mean it's just a text text button json format json format mean you know this is the json format what i just spoke so it is coming in the json format but again it they are string entirely it's a string so if you see the variable the moment you create a variable there automatically the variable type has been assigned a string this much is understood so the data which is coming from the website will come in json format but but again this activity is going to convert you know put that into a string format the output of this activity will always remain a string format because the moment you are creating a variable in the output panel here whatever variable name you give the output variable type will be always be a string type getting it okay now one thing we will be interested is uh can i see that can i see this entire string okay let's do it you can use a message box you can use a log message whatever you like okay so here all i will do i will use uh json string this is the output okay now if i uh debug this or run it right what would happen if you see first thing the http request activity will execute so you are getting you are getting a clear understanding right so that's why i am going very slow so that you understand entirely so now the execution will start okay started the execution uh looks like my studio is quite slow okay so it has started so http request activity has been processed now it is coming to the message box and the message box supposed to show me the entire json data in the preview panel you saw the data right the same data will appear if you if you see the entire data has come in a string format okay code 200 name d e l h i delhi london whatever you the city name you type so entire data has come now this is a huge data isn't it this is a entirely huge data from this entire huge data how do i pull specific informations right for example if i would like to pull only the temperature value or let's say few data temperature minimum temperature maximum pressure humidity so all the set of data i would like to pull how can i do this right how can i really do this okay that is only important right so once you face the data you want to write it into excel file or whatever you like to do with the data you can do it so how this can be done let me show you so let's go back to the studio so until here this is clear how how the data is coming from the output so for this there is an activity because it is coming in entirely string format and this string has got so many things you can't do control f and find right in ui path you have to d series serialize so that every object so every object are there like whether what is the id number uh base what is the right uh base or what is the value for main what is the temperature so there are different objects are there json objects are there so inside the object i have the object properties and the value so to fetch that you need an activity called d serialize json so we are going very slow so that you understand okay that's my intention so i got the activity d serialize json so once i have this activity what i have to do the output of the previous activity right json string i need to type the variable name here json string so i got the variable name okay now again this will have a so what this will do this will do the entire string format what is there it is going to convert all of them to json object so i just spoke what is a json object right few minutes back i was speaking anything which are there in the curly braces are the you know the main one is the before the colon so this is the json object and the entire thing within the curly braces for this object are the object properties getting it so this is the json object this is a json object anything with a colon right json object json object json object so these are multiple json objects available inside this entire set of strings so what this activity will do d serialize it generally will convert that entire string format to json object so that you will be able to access the objects in a different way i'm going to show you that so right now what i'm doing i'll create a variable and i will name it as json object okay just an object if you come here if you go to the variable panel you can see j object is created variable type automatically the moment i created a variable here so this much is understood to you right so decentralization is responsible to just now we saw a message box showing the entire data in string format so this json string will be converted into json object and what is json object is i just spoke about it right so it will convert so it is still in string format so in technical terms in uipath it has to convert itself to json object so when i convert it to json object i'll show you the difference okay don't worry so let me use a message box what i'm doing i'm using a message box okay now here if i type j object json object so now we using the above activity we have converted the json string to json object so i'll use this variable json object okay so json object then what i will do i want to fetch a specific object for example what are the objects can you tell me for example the very first object is this one right so what i will do let me copy this object with a double quote within the parenthesis i am going to enter the value okay so i copied the object name sorry for that so here i copied the object name and with the object name i am just pasting it okay let me show you in a bigger window getting it i got the object so you can do it for any of the objects that are available so let me do it for this one first okay let's see how the output is coming so let me hit on debug okay okay so you can see these two values were there right right so now the value uh longitude this was for london right this was for london okay okay but again these two values have come right longitude and latitude has come coordinates this means coordinates these two values have come so you understood it okay very good now um what we will do now why you have to use digitalization let me tell you for example because because of the json object i am able to fetch the specific objects if i use json string if i use json string and within the double code if i put that object name right so what see there is a error you can't do it with the json string you can't do it only when once it is converted to json object then you can fetch the data with this syntax okay so that's why you should use the json object okay now um let's do one thing um let's pull uh what is more important for us is what is that okay so what is more important for us is um fetching this temperature data right so what is the object this all this object properties are there inside the object called main so i should first fetch this data right main so let me copy this object name main go back to the studio here let me so i will show you how to do that how do you write it to a data table so once you write it to data doubles easy for you to write it into an excel file so here i put the okay first i should write the variable object.json object json object and then within the parenthesis i should put the object name so once you put it if you execute this one okay if you execute this one what should be the output what should be the output so the output should show me all the data in the main okay so you can see i got all the data temperature feels like temp max pressure humidity so all these things have come getting it so in the json file if i go back to the json file so i pulled this object name main so what happened everything has come now you have a question rakesh what if i just want to pull only the temperature how can i do that i want only a specific value okay for that the format is slightly different so what you do go back to the studio and here i want to fetch only the specific data right which is temperature so what you do copy this object property name copy go back to the studio and here i'm going to within the double quote i am going to paste the this is the format okay let me show you slightly a bigger screen so the object variable then the first object and the object property after that okay so this is the format if i do this if i um let me run it okay if i run it it should show me only the temperature the current temperature of delhi okay 27.05 degree celsius it is showing getting it so this is how you fetch the uh date specific uh data now you have a question rakish how can i write this data to a um excel file okay so let me show you the trick is very simple all i will do i will use a build data table activity first you can do it different ways okay there are different ways to do it so this is one of the simple way so what i am doing i use a build data table activity so here i'm going to hit on data table and uh let me let me do it only for two values so i cannot do it for all the values so what is the first value temperature let's do it temperature okay string value okay fine and then what other data we need you can do it for as many you want just for learning purpose i'm just keeping it simple that's the humidity right so humidity dt okay this is done this is again keep everything in string values fine and the data table is created click on ok so once this is done next thing is you should create a variable called dt1 okay so i mean any name you can give so data table variable is created now i need to add values to it so what i will do i'll use add data row activity and here in the row this is what uh you need to learn so it should write into data table and the values i will use the array row property okay now here i will put a curly braces and within the curly braces the syntax that i have written previously right json object and then in double quote in the in the within the parenthesis i should first access what i should first access uh main right so i should i should write this the syntax are important otherwise your entire project will fail if you do not write it properly so main right and after that what i want from main i need two different values so uh the first one is temperature so i'll copy this and i'm going to paste it simple so the first value has come and then again put a comma in the same thing let me copy paste so that i don't have to write it twice [Music] okay json object uh main uh and then here uh it should be different one right and why there are double double quotes let me know it should be only single quote okay done let's come here and remove this entirely and then uh what value i need i need humidity so copying and pasting that preview is important so that you can play with the value so copy and paste it into a notepad so that you can do all this okay so this is done putting a comma and there are two different values i want to fetch and all these two values will be written into two columns of the data table which have built okay first one is for the temperature second one is for the humidity it's going to write automatically through this activity so once it's written so you can write it to a excel file or anything you can do let me use output data table just to show you the data you can use right range and all that okay you know that so data table and output data table so i want to output dt1 and then i want to store the data into txt data table i mean it will convert the data table into text format okay so once it converts i want to see that output so i'll use a message box in the message box i'm going to type the what was the name txt right txt dt okay that's all so let's execute let's debug it and see if the uh data dt1 is fetching the data or if the dt1 is is able to get the data or not let's see okay okay so finally you can see there are two different values i've got temperature is 27.05 for delhi in the humidity likewise you can fetch any n number of data okay i'm just giving two different uh humidity 100 okay so i'm giving only two different values but you can do it for n number of things um that you need from the json okay whatever the object whatever the specific so i suppose that's where i gave you the concept around json object json object properties and property values okay this should be if you are clear with this it is very easy to get the data so this is the json object these are the json object properties these are the json object property values okay that's all that's all very simple so you got a complete learning from this video i hope you have enjoyed this and you must practice it you know couple of more times and and see i'm going to see um you know if i can bring more such examples with different different public apis that we can use uh i will try to bring them out and see if you can practice on more such things and i will try to bring some of the advanced topics around this so thank you guys for watching we are going to meet once again in the next video please do support me do not forget to subscribe to my channel guys and please do stay up to date you know i regularly update videos on my channel i have got 500 plus content on ui path alone so you can imagine on a regular basis i try to upload so please do subscribe and hit on the notification icon so that you stay up to date with any content that i'm uploading onto my channel so thank you guys for all the support till now we are going to meet once again in our next content take care bye
Info
Channel: Automate with Rakesh
Views: 18,437
Rating: undefined out of 5
Keywords: api uipath, api call uipath, http request uipath, web automation uipath, uipath web api activities, uipath api documentation, uipath api integration, api, rest api
Id: 98SR0WOFUZo
Channel Id: undefined
Length: 42min 3sec (2523 seconds)
Published: Thu Jun 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.