 Hello, everyone. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So today we are going to learn integration that we are learning from last week. And today Ankit will be covering some more topics like apics call out. And it is part five of integration. And I hope so far you have understood All the concepts related to integration very well. And this is day 64. And we will be having one more session tomorrow. So this week integration related sessions will be completed. So let me welcome Ankit once again. So welcome Ankit on the channel. Please share your about yourself to the audience. Thanks Sanjay for having me on this channel and providing me the platform to share the knowledge with the community. So something about me. My name is Ankit Jen. I am a Salesforce architect. Moreover, I'm also a Salesforce certified instructor as well as a corporate trainer too. Where I'm conducting the trainings for the corporates for more than three years. And I have conducted more than 30 plus batches on the different topics include admin, LWC, Aura, integration, apics, PD1, PD2 and so on. Moreover, I'm also quite active on the communities like this package change as well as the Salesforce developer communities too. Please follow, please share your knowledge with me on these different commentaries too. Thank you. Okay. Thank you Ankit for letting us know about yourself. So guys, if you want to become part of Sanjay Gupta Tech School community so you can join this telegram group. We are people are interacting and helping each other. No promotion and total knowledge sharing. Okay. And this is week 18 of this Salesforce learning boot camp and I am happy like Ankit became part of this boot camp. So it is good. And in future as well, like I will try to connect Ankit and other folks who are having different knowledge because I alone don't have all the knowledge of Salesforce. So I need more people. So whenever I get a chance, like I if I have anyone who is having proper knowledge. So I will connect that book on this channel so that they can share their knowledge as well. Okay. So moving forward, like if you want to follow Sanjay Gupta Tech School, so you can just follow this platform on YouTube, LinkedIn, Instagram and telegram. And all the links are available in the video's descriptions like session tracker and exercise sheet. So just share this information with more folks and over to you Ankit. Let's start the session. Sure. Thank you Sanjay. So folks yesterday we discussed about the Apex REST service where we have created the Apex REST service by using the REST resource. Right. We discussed yesterday how to create your own web service with the help of the Apex programming. Today we will take one step further and we will see now how we can call out another web service. So yesterday basically what we have discussed that was referred as the inbound integration. Today we will be talking something about the outbound integration where the Salesforce have to invoke the web service that is available in some another system. So for example, if you refer this diagram, let's say Salesforce is one system and there's another system that another system can be in the other language. Another system can be running on any other platform. How as a Salesforce, you send the request and accept the response from that web service. What are the different things that you have to take care to send the request and accept the response from the third party system. When I say the third party system, the third party system can be Oracle system, can be SAP system, or can be another Salesforce org as well. We do multiple times I have done in my projects as well where we do integrate two different Salesforce orgs to share the data. Right. So how we can do that, how we can achieve this with the help of Apex programming. In case you have to do it in the Apex, then we have to work on the few classes provided by the Apex. The first class is the HTTP class. The first class is the HTTP class. This class will be used to initiate the request and also this class will be used to handle the response as well. So first class that we have to use is the HTTP class. Another class that we have to use here is the HTTP request class. In this request class, we set the endpoint like we discussed in the past, whenever we have to perform any integration, we have to set the endpoints. And we have to let the system know what kind of request that we are sending, whether we are sending the get request, post request, patch request, boot request, or delete request. We have to go and specify here the request detail as well. Another thing that we do have to set according to the integration requirement. For example, if a particular integration needs to set a specific header, for example, most of the integrations, they do specifically need to set the content type or they do specifically need to set any additional headers. Then we have to set all those headers with the help of this request class. And finally, what we do is we handle the response coming from the third party system using the HTTP response class. So this class will provide different types of methods to check the body, to check the error code or to check the status of the HTTP request. So whenever we are dealing with any race call out, we have to take the help of the three base classes provided by the Salesforce. In addition to that, before you go and make any call out, you have to either go and register the third party endpoint, either as the remote site setting or as the name credential. In one of the previous session, we already deep dive into what is remote site setting and what is name credential, right? So for example, if Salesforce have to communicate with another system, like Oracle system or another Salesforce system, then the first thing that we have to do here is we have to go and register that endpoint as the remote site setting or as the name credential. Salesforce do recommend that we should use the name credential over the remote site setting because name credential provides few additional functionalities, like with the help of name credential, we can go and also specify the authentication details as well. Right? So for today, I have prepared one demo. So what we will do in this today's demo is we will go and we will have the two different systems here, just a minute. We will have the two different systems here. One is the system A and second is the system B. Yesterday, we have created the REST service on the system A. Now let's say I do have another system B, which is again designed in the Salesforce. So I do have two systems, both are in Salesforce. System A is in Salesforce and system B is also in the Salesforce system. Now from the system B, which is again a Salesforce system, what I have to do, I have to call this REST service that we have created yesterday. So what are the different things that we have to take care to invoke the REST service from the system B? First thing is on the system A, we have to go and create the connected app because we have to do and define what kind of authorization that user will have whenever user is invoking this REST service. So here we have to go and create the connected app and set the authorization details. On the system B as we are making the call out to the third party system, we have to go and create the name credential. create the name credential. On the system B as we are making the callouts to the third party system we have to go and create the name credential and for the OAuth setup we have to also go and create the authentication provider as well. For the OAuth setup we have to also go and create the authentication provider as well. Let's do these steps one by one so that the things will be more clear. Again I am navigating to my developer console so here we do this is the system A that I do have where we have already created the rest service yesterday. This is the rest service that we have created yesterday which is returning your top accounts right which is returning your top account. Now what we will do we will invoke this rest service from the another OAuth. This is my another OAuth integration demo OAuth 2 and this is my first OAuth integration demo OAuth A. Now from this OAuth what I will do I will invoke this rest service. As I said we have to follow the certain steps the step number one is we have to go and create the connected app where we do have the rest service available. So I will go and create the connected app here. Create the connected app what you have to do here is again we already discussed this in the previous sessions what we have to do to create the connected app is we have to go and click on the setup and in the setup we have to go and search for the app manager. So let me look for the app manager here and here we will go and click on the new connected app. Here we will go and click on the new connected app. Of course that what we will do we will go and create the connected app you can give any name to the connected app. Let's say I am giving the name here as the Salesforce to Salesforce integration. I am just giving the name here as the Salesforce to Salesforce integration. Contact email go and specify a valid email address because Salesforce will drop an email to you as soon as the connected app is ready. So go and specify the email here again it is not mandatory in case you want. Sorry to interrupt can you please zoom in actually it is very a little bit of yeah yeah I have specified here the connected app name API name after that I have specified the email address was that you have to go and specify the image URL again it is completely optional so I am skipping it for now and I am creating this app for the OAuth setting. What I am doing here is I am creating this app for the OAuth setting so we have to go and check this flag. So here we have to go and check this flag again for the time being as we do as we do not have the callback URL just go and put any dummy URL for now so let's say I am putting here a kind of a dummy URL of a Google will come later and replace that URL but for the time being here I go and put a kind of a dummy URL of a Google. Next thing is here we have to go and specify what all different access that we have to provide. Here we have to come and specify what all different access that we have to provide so let's say to exchange the data we have to go and specify here the managed user data access so I am adding that access here another access that I am doing here is because I want my connected app to be taken care for the refresh token as well so here I am adding another thing that is the perform request at any time and let me also give a complete access because we are on a demo definitely we can also give the complete access here as well but according to your business requirement you have to figure it out what kind of access will work for you this is how you go and configure the connected app for the auth only check this flag when callback URL I will come back to that callback URL right and post that scroll down and click on set again as I said it will take some 10 minutes to configure the also with that all gets configured in the background as soon as we go and create the connected app Salesforce do share the client key and the client secret key so let's go and access that client key and the client secret key by clicking on the button manage consumer details so again here it is asking me for the verification let me check for the verification code that I am receiving on my email is double one five and click on right so I do have this consumer key and the so the system a job has been done I'm just following this diagram that I have put here on my system a I do have the rest service here I have created the connected app and after creating the connected app what I got I got the client key and the client secret key in fuel they also refer to the consumer key on the consumer secret key but it's one and the same thing right let's go to the system B from where we have to make the call out so the first thing that we will do there is we will go and create the authentication provider because this authentication provider will go and specify all the details that we have got from our connected app so here I go to my another out this is my another out here I go and create the authentication provider to create the authentication provider you just have to go here and search for the OAuth provider OAuth provider so here I'm clicking on the OAuth provider and let's go and select the kind of OAuth provider that we have to use for the authentication since first do have provided few of the OAuth providers here so if as soon as you go and click on new you can use any of the OAuth providers different OAuth providers provided by the Salesforce so with the help of these OAuth providers you can go and connect with different types of system like you have to connect with the GitHub or you have to connect with the Microsoft or Mulesoft or Salesforce or Twitter or LinkedIn you can do this with OAuth providers for their own type of authentication here I have to connect the integration I have to do this integration with another Salesforce auth so I'm selecting here the Salesforce OAuth provider let's say I am giving the name here yes as the Salesforce connect app because I am creating this OAuth provider for this connect app so connect for the connection app that I have created on the org you can do any name here it's completely up to you the next thing that you have to go and specify here is the consumer key and the consumer secret key that we have received after we have created the connected app so here is my consumer key I'm copying this consumer key and here I go and paste that consumer key similarly I will go to the consumer secret and get the consumer secret from here again copying the consumer secret and testing it here next thing is for the Salesforce this is only the authorization URL so in case you are not putting anything it will take the default URL which is already provided in the placeholder in case you are doing the integration with some other system like LinkedIn or Microsoft their documentation they will give you what kind of authorization URL or the token endpoint URL that we have to use another key thing that we have to specify here is the default scope another key thing that we have to go and specify here is the default scope so from where we will get the default scope again to get the default scope we have to go back to the connected app that we have created here you can see the default scope that we do have here is the these are the different scopes like you can see API full what kind of access that you have provided here right accordingly the codes will be generated so here you do have the different types of scope available API scope full scope refresh token scope so you can go and specify the different types of scopes in your authentication provider you can specify one or more than one as well how we can specify that so let's say I have to go and specify this refresh token as the scope so I'm copying that scope from here and again navigating to my authentication provider and putting the scope name let's say another scope that I have to go and specify here again from my connected app is this full scope so to specify this additional scope you just have to make sure that you are putting one space in between the scope this is how you can go and specify the multiple scopes here once this setting has been done you can go and click on the same you can see here Salesforce have automatically considered it is your org URL as well as the token URL in case you do have something else you can go and edit and put your own URLs here the key thing that we do have here is the callback URL right so from here what we have to do we have to take this callback URL and go back to our connected app because in the connected app we have put kind of a dummy URL for now so here we have to go and put the callback URL that we have received from our authentication provider so I have got my callback URL and here I go and put my callback URL here I go and put my callback URL so from where I am getting this callback URL from this authentication provider I am getting this callback URL and clicking on the again I am navigating to the same diagram so connected app has been done authentication provider configuration is also completed next thing that we have to do here we have to go and create the name credential because we have to white list our system so we will go and create the name credential again name credential also I am doing it in the another system from vector to do the cost so here and name credential now so let me go and create the name credential from here again you can give any label let me give the label zoom in please sure it's around 150 yeah now it is okay okay so the label that I have given here is the SFDCB you can give any label it's completely up to you now here you have to go and specify the URL where you have to here you have to go and specify the URL where you have to make the connection so for example I have to make the connection with this org so I have to go and specify the URL of this org one way to generate the URL is you can directly use the command provided by the Salesforce that is a system dot debug and here you can use the system dot URL dot get Salesforce base URL so this method it will give you the base URL of your org that you have to connect so I'm clicking on execute and generating the base URL of the org so this is the base URL of the org that I have received so I'm just copying the base URL of the org from my system a how I have generated the base URL to generate it the base URL I have used the apex method that is the system dot URL dot get Salesforce base URL so whenever we have to generate the get the base URL in our apex code we generally use this method to get the base URL I have applied a similar analogy here as well and I got my base URL that I have put in my name credential another thing that I have to go and specify in my name credential is the authentication so what kind of authentication that we have to do here so here let's say I am doing the authentication as the OAuth 2.0 what kind of authentication that I am doing here is the OAuth 2.0 so here I go and specify the OAuth 2.0 immediately it will ask me to select the authentication provider we have already created the authentication provider so let me select that authentication provider that we have created just before creating the name credential so this is the authentication provider that we have created so I am selecting that authentication provider right and post that what I will do here is I will go and click on save as soon as I go and click on save you can see here authentication status by default guys I think Ankit lost the connection so let's wait for a couple of minutes just just wait for two three minutes he just lost the connection due to some internet connectivity so he'll be joining soon yeah he's here okay okay I'm back yeah yeah please carry on okay sorry I lost my connectivity so let me refresh this to check the status of the name credential okay let me start creating the name credential one more time uh I'm not sure from where we have lost so what I will do here is I will go and specify here the label you can give any label it's I am giving this as the label here the URL you can get the URL from the system that you are connecting either you get this directly from the documentation or you can also generate the URL by using the method that is the system dot URL dot generate base URL right by using this method you can go and generate get your base URL so after you got the base URL go and paste the base URL here next thing is you have to specify the authentication how you want to do the authentication here so I'm specifying here the authentication type as the name principle and here I am specifying the authentication protocol that I have to use here is the OAuth 2.0 the next thing that I am doing here is I am selecting the authentication provider that we have created before creating the name credential so here I am selecting the authentication provider next thing that we have to do here is we have to go and click on the as soon as you go and click on the show button what will happen the name credential it will initiate the authentication and this authentication status will be authorized as soon as the authentication is completed initially it is pending as soon as we go and click on show and once the authentication is successful the status will be changed to authenticated not sure it's a connection issue or something let me go and check if the name credential is created and we will try to authenticate one more time so the name credential is here I am again selecting the name credential and that's all the things looks good to me let me go and click on the show button error redirect urm mismatch error description is equal to redirect urm match configuration let me go and revisit all the settings that I have done looks good let me revisit for the authentication provider sometimes you also get this kind of an error because our connected app is not ready so that might be one of the reason authorized token this is good let me again paste the consumer key and the consumer separate key might be there is an issue in pasting manage consumer details proof for it says evaluate proof for it says evaluate click on verify let's try one more time now this time it is moving you can see this time it is asking me for the authorization of the ork so let me go and put my ork details and click on share while doing this authentication it is asking me to allow the access I am just clicking on the allow button to allow the integration between the two different Salesforce orks now we are expecting that the status of the name credential must be converted as the authenticated you can see here now my authentication status is converted as the authenticated as I am authenticated with my org now this is the integration demo ork you can see here I am configured authenticated here to my integration demo org now right now what we will do as a part of next step as we have already authenticated this org now what we will do in another system we will go and create the new apex class to do the callouts so here I am creating the apex class that is I'm naming that apex class as a callout to let's say putting as Salesforce or again let me zoom this I'm just giving the class name here as call out to Salesforce or and clicking on ork right now in this class what we will do we will make the callouts so which method we have to make a call for example here we are making the call to the method that we have or the apex service that we have created yesterday that is the get top accounts so how we will do that so let's say I'm creating one method here public static void I'm just giving the method name here as get account you can give any name I'm just giving the method name here as the get accounts in this method we will make the call out as I said whenever we have to make the callouts we have to use the three different classes what are the three different classes that we have to use sttp class sttp request class as well as the sttp response class so we'll go and use these three different classes now initially we have already taken care of the authentication part now we just have to make the callouts to our org to get the response from the third party on so here first I am defining the sttp class instance sttp is equal to new sttp this is my sttp class instance taking the one step further here I am putting the sttp request is equal to sttp request is equal to new sttp request I have created the instance of the request class as well now in this request we have to go and set the multiple things so we have created the instance of the sttp class we have created the instance of the request class as well now in this request we have to go and set the multiple things so first thing that we have to go and send set in this request is the end point so set end point the first thing that I I am sitting in this request is the endpoint. So what will be the endpoint and how you specify the endpoint whenever you are using the name credential. Again, if I can recommend you, remind you to the postman, you have stated this was the endpoint that we are using. Whenever we are testing the integration with the help of the postman, so initially I do have my instance of the org, right? Followed by the slash services, followed by the slash updates rest, followed by the URL mapping, and this is the URL mapping that we have done. So we'll apply the similar analogy here. I do have the endpoint configured on my name credential here. This is the name credential that I have created. And in this name credential, I do have my instance URL. So we can directly use this name credential in our code. How to do that? In case you have to use the name credential in your code, first you have to go and specify the call out, followed by the colon, followed by the name credential name. So what is the name credential name SFDCB? So here I'll go and put the name credential name as the SFDCB. Next thing that I have to go and specify, like we have done yesterday, here next thing that we have to go and specify here is the slash services, followed by the slash updates rest. So here I'll go and put the slash services, followed by the updates rest, followed by the updates rest. Next thing that we have to go and specify, again, like the way we have done in the postman is we have to go and specify the URL mapping. So what was the URL mapping? That we do have account management. That's what we have configured yesterday. So I'm copying the same URL mapping here and putting it here. So basically this is the endpoint with which we have to make the call, right? We have already tested our classes with the help of the postman yesterday. Now I am invoking this same rest service from my another Salesforce call. So I have defined the call out here, followed by the slash services, followed by the updates rest, followed by the class name, followed by the URL mapping name. So this is the one thing that we have to go and set. Another thing that we have to go and set, that is the method. So set method. Another thing that we have to go and set is the method. So on which annotation we are invoking this method, we are invoking this logic on the iterate HTTP. We are invoking this on the iterate HTTP gate. So here you go and specify the, sorry, here you go and specify the method as the get method. Here you go and specify the method as the get method. Again, according to the documentation, you have to go and configure all the different parameters. Like few of the documentation, they do require you to set the different headers like set timeout. So here you can go and set the timeout. According to the different documentations, you have to go and set this. For Salesforce documentation, only these two things are enough for now. Right, so I'm just keeping this to for now. And let's go and make the call now. So to make the call, what we have to do, we have to go and call the send method from the HTTP. So this is my HTTP. Here I am calling the send method. And with the send method, what you have to do here is, you have to go and send the request. What you have to do here is, you have to go and send the request. What it will return, it will return you the HTTP response. What it will return you the HTTP response. Again, I am repeating, you have created the instance of the HTTP class. You have created the instance of the HTTP request. On this request, you have set the different parameters like the endpoint or the method. And here you are calling that method by using the, here you are sending the request to the customer and handling that response by using the response method. All right, now let's go and check what all the response we are getting by making this call out. So to check the response, I am just putting this under the debug, system.debug. To handle the response, you can use the response. Let me put here as the response. You need to have the multiple methods are available here. Like we are just accepting the body. So I'm putting the get body. In case you are doing the integration with the documentation or with the ascending the PDF, then accordingly you have to go and accept here the different types of data. So let's say here also I'm checking the status because yesterday only we discussed whenever we are getting the successful response, what response code that we will get, we will get the response code as 200. So here also I'm expecting the response code as 200. So here I go and check the status code. So here I am putting the get. Status code. Let's go and check whether we are getting the body as well as we are getting the expected status code or not. So again, I'm saving this one, but where is, let's go and invoke this method now. So again, I'm invoking this method from the anonymous window. What is the method name? Let me get the method name here that is the get accounts. Let me go and click on execute. And click on the labor only. You can see that we are getting all the accounts from my another org here. You just can see here, we are getting all these different accounts from my org. Right, so we are getting this kind of a response whenever I'm making the update call. You can also download these logs and get the complete response from there. So let me just download it. You can see here, this is the kind of a response that I am getting from my third party org. Now it's very easy. You can either directly send this back to your, in case you are invoking this from your LWC component, you can directly send this response to your LWC component and navigate it and show it on the UI. Navigate it and show it on the UI. You can also parse this in the, you can also parse this kind of a response in the, in your Apex code as well. There are few classes, JSON classes, there's the one JSON class provided by the Salesforce in which we do have a few methods with the help of which you can deserialize it and get it into the form that you are expecting. So let me quickly show you that as well. So what you can do here is, whatever the response that you are getting, first thing ideally what you should do here is do and check here whether you are getting the status code as 200 or not. You can check here. In the case of successful response, what we are getting, we are getting the status code as 200. So here I go and put that check if the response code is 200, then and then only I will go and perform my logic. Else what I am doing here is I am reporting the error. So system.double, let's say I'm putting the error message here, error in, and the error in integration. And here again to get the error, here I'm using the method response.getBody. Because we do have the error also available in the body itself. So here I'm just directly printing the error. So in the case of successful response, what you can do, you can go and deserialize that response. To deserialize that response, you can use the JSON class. And in the JSON class, we do have the multiple deserialization methods. So here I am using the method called deserializeUntype. What this method will take? This method will take the JSON string and what it will return? It will return you the object. What it will return you? It will return you the object. So here I am taking the, I'm using this method. And in this method, what I am passing is the body that we have issued. And what it will return, as I said, it will return you the object. So let me go and handle here the object. So list of objects. Let me put here the results is equal to, because we have to also do the type conversion here because one is a string and another one is returning the result. So here I am doing the typecasting as well. Here I am doing the typecasting as well. Now I got the result. It's very simple. We just have to iterate over this result or the list the way we do the iteration in the HPEX by using the for HPEX loop and we can access all those details. So here I am doing the similar iteration. So let's say here I go and put OBJ object, let's say OBJ of results. And here we can go and convert this object now into the map. We can also go and check what kind of objects that we are getting. So let me go and put this like this so that you'll get a better understanding what we are getting now after we have converted this into the object form. So command this and the command this now because we already tested the response. Now what I have done in this step, I have converted the object or the output that I have got into the object form and here I am just printing the object. Let me again invoke this. You can see here now we are getting a object. Now what we are getting here is the object. Now it's very simple. You just have to convert this object and access this different value. Here you can see everything is in the map form like this is the key and this is the value. Again, this is the key, this is the value, this is the key, this is the value, whatever the things that you have to retrieve, you just go and convert this into the map form and access all those values here. So let me show that as well. This is how you have to break your code, understand it, what each step is doing and after that you can perform the different operation. So here again I am converting this into the object. So let's say I am putting the string that is the key because if I go and read the output here, you can see everything is the string. But the next thing that I do have somewhere I do have the integer value, somewhere I do have the string value, somewhere I do have a complete object. So let me generalize it by putting this as a, so what I am doing here is I am just generalizing it by putting the value is the object. And let's say here I am putting the name as the account record and here what I am doing here is I am converting this into the map. So here again I will go and do the typecasting and put the object here. Again, I do the typecasting and put the object here. After that it is very easy. From the map, how we access the value, the similar way you have to go and access the values as well. So let me go and put it into the debug. So let's say you have to go and access the dot get. Let's say you have to go and get the account name. So I am putting the account name here. Let's say I'm only accessing the account names, whatever the accounts that I am getting, I'm just printing that account's name from here. Let me go and save this and we'll execute it one more time. So let me comment out this now. It's not required and I'm just printing the names now. So here I go and execute one more time. This is how you can perform the real time. Okay, we are getting the null. We have to check why. Let me check. Are we not getting the name here? Okay, we are not getting the name here. What we are getting here is the annual revenue ID as well as the industry. So there are two things that we can do. Either we can go and modify the rest service to send the name or we can directly access the value that we have to. Because here we are only getting the annual revenue ID and industry. Let me only access the industry here for now. So here I am putting the industry. Clicking on save. I believe here we are not getting the, we are not sending the account name here. You can see here as we are not sending the account name, that's why we are not getting it. In case you want to access the account name add one additional parameter in the query that is the account name. So that the third whenever the third party system is making the call, they can also access the account name. But for the time being I'm just accessing the industry. You can see here all these industries value. So this is the one way of doing it. In case your output is kind of a easy, you can definitely use this approach. You can use this approach. Another way we can, another way that we can do to pass this kind of output, we can use the JSON to Apex utility. It is one of the utility provided by the Salesforce with the help of which what we can do here is we can convert the JSON output into the Apex form. So you just have to go here and paste your JSON output and this utility will create the Apex class for you along with the parser. What you have to do here in this utility, you just have to go and paste your output. So this is the output that I have received from the third party system. So this is another way of passing according to the complexity of the JSON that you are getting, you can choose one of the approach. I'm just pasting the complete JSON and clicking on the create Apex. What this utility is doing? This utility, it will create the two class. One is the Apex class and another one is the Apex Test class. So let me go and open this one. You can see here, we do have this utility available here. From this utility also, you can directly get all these different values here. So for example, this is my class, what I can do here is I will go and create the similar class in my org by copying the exact code. Let's say here, I'll go to my org and create another Apex class. Let's say that is the account response helper. I'm naming this class as the account response helper and whatever the class that has created by the utility, I'm just pasting that exact class here. In this class, that utility have created, we do have one method, this is the issue. Let me go and replace this JSON to Apex with this one. Ideally, whenever we are creating this class, here we have to go and specify the class name. I miss that, that's why I'm getting these additional errors. If you go and put the class name here while passing, then you will not get these errors. But let me fix these errors quickly. I believe we are good now. So in this class, we do get one method that is the pass method. Internally, again, pass method, it is using the JSON classes only. But your job only is to call this pass method and pass the output and what you will get in the response is the account helper. What you will get in the response is the account helper and here you are getting the lead of an account helper in the response. So another way of parsing is, let me close this. Either you can use this approach that I showed you here or what you can do here is, you can you hear the list of account helper is equal, let's say here, account list is equal to, account list is equal to, here you go and call the pass method of this class. So here I go and call the pass method and in this pass method, what I am doing here is I'm just passing the body. In this pass method, what I am doing here is I'm just passing the body. Now again, here also you are getting the account list. It is again very simple to iterate over this list and get the data. Many more. You are missing some of the closing rest, but that's fine for now. That is not the main crux. The main crux here to show you folks how we can use this account list. Now you got the account list. Again, you can perform the iteration for account ACC of account list. And here you do have all these things here. So let me go and put here system.debug, not sorry, this one ACC of account list, system.debug. And here you can go and print the ACC records here. Whatever the ACC records that you are getting, you can directly put that ACC record or if you want to access any of the property, let's say if you want to access the industry, you can access the dot industry here. If I go and debug this, again we'll get the similar kind of an output. So it's completely up to the kind of a complex JSON that we do have. Accordingly, we can pass it. I have shown you both the ways that people do use in the industry. Two people, they are comfortable with this time of passing. So you can also pass in this way by using the JSON to affect utility provided by the Salesforce which is hosted on the hero group. And another way is you can also use the classes provided by the Salesforce like the JSON dot, is realized on type class. In this way, you can make the connection in between the two different orgs. Again, I am repeating the steps, system one, system two, system one, where we do have the rest service, we go and create the connected app, system B, from where we have to make the callouts to get the data. So here we go and first create the authentication provider. In the authentication provider, we go and put the client key and the client secret key that we are getting from the connected app. And in post that, in the authentication provider, we'll get the callback. Similarly, we go to the connected callback and configure that callback method. In the end, we have to go and configure the name credential by using the authentication provider. As soon as we go and configure the name credential, system will initiate the authentication process and it will mark the authentication as stressful. This is how we can go and integrate between the two different orgs. Let me check if there are any questions in the chat box because of bag network, I believe I lost all the questions. Okay, let's do it. I got the questions and just let me go over it. When should we use the HTTP request and the HTTP response class inbound or outbound or both data integration? We use the HTTP, so Sachin asked the question, when should we use the HTTP request and the HTTP response class in the inbound integration or the outbound integration? The answer is we should always use this in the outbound integration. In the inbound integration, Sachin, we go and create the rest service. Okay, what if we have the system B as non-sales for system? What additional things needs to configure? Again, no additional things like for example, if you have to make the integration with the LinkedIn. Let's say, for example, you have to go and make the integration with the LinkedIn. Let's say what you will do, you will go and search here for the LinkedIn developer, okay? Here also you will do the same thing, like we have created the connected app for the Salesforce. Here also you go and create the app. If you go and pick any system which supports the authentic, which supports the OAuth, they do provide you this kind of option. If you take the Twitter or you take the Facebook or you take the LinkedIn or any app which does support the OAuth 2.0, it will provide you this functionality that it will allow you to create the app. After creating the app, the rest of the things that we have done is exactly same. Put in the scopes of the name credential. So Praveen asked that question, what we have to put in the scope of the name credential. Again, you have to follow the documentation Praveen in case you are doing the integration with some third party system. As we are doing the integration with the Salesforce, here you can see we do have the different types of scopes available. We selected OAuth Scope in our connected app. If you go and create the connected app with the LinkedIn, they will specify what type of scopes that will be supported by your application. But accordingly you have to go and define the different scopes here. Sachin asked the question, what's the difference between the either HTTP get and the request.set method get. So either HTTP get, you will use Sachin whenever you have to create the rest service and you will use the request.set method get whenever you have to do the outbound integration. Because de-serialized untyped, it does provide Sachin asked another question, why we did not use another de-serialized function. If you check Sachin, you can use that one as well. I choose to use the de-serialized untyped because it is quite easy to use. But if you check here in the utility that we have created internally, they are using the de-serialized another de-serialized function. So you can use another de-serialized function as well. It's completely your choice, but accordingly you have to handle the output. Accordingly you have to handle the output and do the type conversion. In line number 14, can we do the de-serialization? Yes, according to the output that you are getting proven, accordingly you have to decide what type of collection that you have to use, whether you have to use the map collection or the list collection. It's completely driven based on the output. So Archana asked the question, will refresh token generated internally or the refresh token, do we have to hit the refresh token API? So Archana, no, we do not have to hit the refresh token API because we have created the name credential here and your name credential will automatically generate the refresh token for you, right? You do not have to bother about generating the refresh token again and again. Archana asked the question, how to achieve server to server authentication to avoid the token verification? No, in every integration, Archana, you have to do the authentication. You cannot avoid the token verification in any authentication. Like here we are doing the server to server authentication only. From one Salesforce org, we are connected to the another Salesforce org. That is nothing but a server to server authentication. So the best way to do the authentication is definitely the OAuth. That is the system, that is the complete web, all the web application, they are following the OAuth integration. It is considered as the most secured integration. You do have the OAuth 3.0 as well, but as of now, I believe Salesforce is not supporting the OAuth 3.0. What's the difference between the process integration and the data integration? Sachin, you will get the answer of this question if you go and revisit the second session of this series, there I have explained what is the difference between the process integration and data integration. I highly recommend you to please go over that. There's an option to run the SOC world TML on our own platform like PHP, use the curl. Now, the question is not clear to me. The question is there's an option to run the SOC world TML on our own platform like the PHP using the curl just by creating the connected app on the Salesforce. Is this a good way or we have to use the rest resource every time? Rest resource, I'm not sure whether I answered your question correctly Vinay. We go and use the rest resource whenever we have to access the resources that is coming up from the request, right? That time, we go and use the rest resource. Connected app we use for the authentication purpose. Again, as I said, I'm not clear with your question. So most likely not be able to answer it in a fully way. Yes. So Manoj, whenever it's not always required, whenever you have to do the integration with the help of OAuth 2.0 or with the help of OAuth, then and then only connected app is required. In case you are doing the API key authentication, for example here, this type of integration here, there is no OAuth. They are just providing the API key and we have to do the authentication with the help of this API key. In such scenarios only we have to go and in such scenarios there is no need to go and create the connected app. Whenever you have to use the concept of OAuth, then and then only the connected app will be required. I believe most of the folks do have the request to show the integration between the two Salesforce orgs. I believe that request got fulfilled now. Yeah, that's all from my side for this session today. Back to you, Sanjay. Thank you, Ankit, for sharing the knowledge and I hope guys you have understood whatever Ankit explained. And I think total five sessions are done and one more session will be happening tomorrow. So this way like all the integration related things will be completed. And you can just go through all the sessions, practice and if you have any doubt, you can just utilize the Telegram group. Thank you, Ankit, for sharing the knowledge once again. Thank you, Sanjay, for hiring me on the platform. Yeah. Thank you.