How to create a REST message in ServiceNow | 4MV4D | S01L10
[Music] in order to subscribe to my channel please click here or click here please share comment and like my videos and channel hello guys welcome back to sas word service now this is part of servicenow four minutes video for developers this is the next lesson of series of rest integration in service now in this lesson you will learn how to create an outbound rest message record in service now now this is my personal developer instance so let's say let me let me start with the scenario let's say you have to integrate two service now instances now in order to show you this demo i'm going to use two personal developer instances so if i if you will see over here this is my one instance and if i go to here now this is my second instance so let's say we will treat this one as our primary instance and this one as our secondary instance now this primary instance basically whenever maybe let's say i have to uh i have to integrate this primary instance with this secondary instance so in that case i have to create a rest message record over here and how exactly i will do that i will create that trust method record and have to put the information of the web service provided by the second instance that's what we do and that's what we just learned in our previous video that in order to connect to this particular instance i have to put the information in primary instance by creating that rest message racket so what we will do we will start by creating a new rest message racket so that we can basically uh connect to that secondary instance so what i will do if if i go to web services so you will find this rest message module under web services so that is system i would say system web services so we have this system web services you can see uh you will see here under outbound you will see this rest message now this is for outbound rest message if i will click over here it will open the basically out of the box module in my system as of now you can see it has only four rackets in this particular instance what i can do in order to create this i just have to click new button over here so if i will click on this new button it will open up the form now here it is asking me a lot of details now what details these are now these details should be from this system but what what details i need to give for that we have to basically get the details from this system so what we will do we will go to rest api explorer and that's how i can get the details of this instance because that's out of the box so if you will go to rest api explorer and what we will do we just want to maybe uh fetch incident data in that instance in that primary instance let's say that's that's one of your one of your use case so i will just click on explorer now what i will do i will select over here uh retrieve rackets that's fine we can just keep retrieve records and i will provide the table over here i will because i'm going to create those details so that i can put in that instance so i will put it over here and then i have let's say i have uh i will do one thing i have this table name selected but i also want to maybe provide some this query parameters because that's what i can put it in my another system so let's say if i come over here i will um maybe i will open all incidents if i will have all incident data in this instance and i will just try to filter it because i will that get basically query uh let's say i just need to i just need to fetch the data related to maybe this one if i do show matching let's say i i do like this and i will do one thing i will copy this query so i will do copy query i will go to my api explorer i will paste it over here and then if i go little bit bottom you can see i have this request format response format and as of now authorization is send as me that's fine i will just click on send if i will do that this will definitely return the response for me in this rest so you can see i have got the same incident over here what i will do i will provide these details what details over here from we will provide these details from here to our primary instance so what i will do i will just copy this one till here let's say i will do like this that's it till till here and then i will come over here come to my primary instance and here i will do let's say get or maybe integrate integrate with another service now now here i have to provide the end point end point i can just give like this here i have authentication now as of now because i can't connect to that third-party system that's another service now instance until i provide any kind of authentication so what i will do i will use basic for now now i have to use so you can see i can select oauth 2.0 or i can select basic as well so let's say i i have to select the profile what i will do i will provide the username password so i have to select the uh basically username and password for that instance so let's say maybe i will i will just mention over here i will create a new one i will do dev um dev70731 and here i will provide the we will do it with basically admin account let's do that with admin i will provide the password which you can't see uh and i will just click on submit i'm done and i will go to http request now here you can see it is asking me for headers i'm not going to provide over here because we will provide in our get method so for this rest method record i'm done so i will just click on save so you can see this rest message record is created now if i go over here at the bottom you will see the there will always be one method will automatically be created whenever you you will create a new new rest message record you will always see that the default method will be created and it will always be get so you can see here we have default get and it has selected get method as well so if i if i just click on this you will see those details as well so now here we will provide more details now so as of now i just created the rest message bracket now here are the main details which i have to provide so that it can perform the operation in another instance that is your third party application so in that case i will select in authentication i can just select this inherit from parent if you want another you can also select that it's totally up to you as per your requirement or it's up to the developer administrator how you want to configure it so in that case i will maybe here we will go to http request our url will still still be the same because that's what we have it for get and if i go to http headers now what headers i can put over here if i go to my another application here and this is you can see headers and that's i would say uh that's a great functionality provided by servicenow it's very easy as a developer you don't have to look uh things from scratch it automatically giving you on your plate ready i think it has already cooked it and given you giving you on your plate so you can see we have this headers i have to add these headers over there so let's say i will do accept and if i select accept and that means i only accept format which format that is over here that is json if you want to accept an xml that is also you can mention over here so and i will show you here as well let's say i here you can see like request format i have maybe response format i will make it xml let's see and if i click on send you will see that i am getting response in xml and that's what you will see the change except so that means i will accept the response and xml that's the reason and what type of data i want to send it to you i want to i will send it to you in json and that's what you can mention over here but this is get and it's it basically here you don't have to put any kind of request body so even if you don't mention a content type i think it won't matter so what i will do i will just mention accept and i will go here so here we have application uh slash json and this is done for headers we are done now we have query parameters have we added any query parameters answer is yes the quality parameters we have starts from here the first one is let's copy this put it over here you have to put the value and that value is like this i will put it like this then i will also select this limit i can do like this and let's say i will just put one even if you will put 10 it won't matter because as of now only 10 uh one racket will be returned so you can see i have mentioned 10 now i can just click on save so if i click on save our get method is ready so i don't have to put any other detail here you can see variable substitution but we don't have to use it right now this is for dynamic data and in our in our i would say further lessons like subsequent lessons you will see that i will be using it because i will be integrating properly end to end with some other application that i have planned for a youtube integration as well so in next sessions you will see integration with youtube as well so here i will not use this but what i will do because this lesson is specifically that how you create a rest message record so what i will do quickly i will do a test so as of now i have given the parameters as i have given the headers i have given the authentication details now i will click on test now this test is basically to use whether you are able to get the data or not if you will click on test you will see the results absolutely did you see that test is successful how did we come to know that this is successful the reason behind it we got this 200 status now this code will always identify whether the connection was made successful or not or whether the operation you want to do whether it was successful or not this will also define the error so you might go get some different uh different other codes as well as status like 401 maybe those codes that means there is an error in the system now basically if i talk about these web services code http codes you have different codes for different errors for example 401 not connected you have 500 uh error it's like internal server error and there are other as well but if i talk about 200 and 201 that means 200 says that hey i was able to connect that application and 201 says that hey i was able to create the record in that another application that's what you basically you will be able to identify here you can see i'm getting the data in json and this is the same incident it's not any other incident it's same uh zero uh the one um let me let me check as well if i quickly check you can see this is the same instance and if i search for number let me search for number quickly absolutely you can see this is zero zero two over here if i come over here this is again zero zero two that's how you create a rest message i will still do one thing just to show you another type of test if i come over here and i basically change this http request parameter so here no headers not parameter in headers if i change this to xml what will happen you will see the magic if i click on save and this time i click on test the result the response will be totally different so if i click on test so now you will see the response is in xml format so basically here it says the default get here the status here the end point which you are hitting here the parameters that you are sending here the content what content you are sending to that third-party system as of now it just gets so i'm not sending any content and here we have response that what response you're getting after hitting that system what response see this is another instance and this is that this is again different instance but i'm able to get the racket the details of another system into this system and that's what integration is all about but this is how you create rest message record in service now
https://www.youtube.com/watch?v=Oa0FyQECfsc