 Hello everyone. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So just want to check guys whether am I audible. So please reply in the chat if you are able to listen my voice. Ankit, I think you need to share different screen. Or is it? Let me stop sharing. Okay. This is great. So welcome folks on the channel. So today you can see we are having one more session on Salesforce integration. And today is day 63 of the Salesforce Learning Bootcamp and week number 18. And I have Ankit with me. So welcome Ankit on the channel once again. New week, new energy. So over to you. Thank you Sanjay for having me on this channel. Hope you all are doing well. Let me start with my brief before we go forward. So my name is Ankit Jen. I do have more than 10 years of experience in the Salesforce ecosystem where I worked as an architect and also as an instructor where I have provided the corporate training for more than 30 plus different corporates on the different topics include the admin, LWC integrations, CPQ as well, Cloud and service clouds as well. Moreover, I'm also very active on the LinkedIn as well as on the various communities including the Stack Exchange as well as on the developer community too. That's all from my side. Back to you Sanjay. Thank you Ankit. So guys, if you have any doubt, you want to discuss things with like I just created this telegram group for the freshers who are struggling for the job. And experienced professionals, those who want to switch their job. So you can join this telegram group where lots of like more than 2000 people are connected. And you can discuss your doubts with this telegram group. Going forward, you can see like second phase of this bootcamp is going to end this week. So in first phase, I covered admin and flow related topics. And in second phase, Apex trigger test classes, SNK picks, visual force and integration are covered. Right. And third phase of this bootcamp will be LWC. So if you have not followed Sanjay Gupta Tech School, so you just follow it on YouTube, LinkedIn, Instagram and telegram so that you can be updated about the upcoming initiatives by me. And all the important links are available in the description. So just follow and please share review or feedback about this integration related part so that I can pass that feedback to Ankit. So like feedback always improves us. So feedback will be like requested if you can share. And with this note, like I pass mic to Ankit. So over to you, Ankit. Thank you, Sanjay. Again, welcome to you all. Good morning, good afternoon, good evening, according to your time zone. So till our last session, we have discussed that how we can connect postman with the Salesforce API. Moreover, we have also discussed how we can invoke or how we can use the standard APIs provided by the Salesforce by invoking it from the postman. Sometimes we do have the few complex scenarios where we have to go and create our own API. Definitely Salesforce have provided the good number of APIs, but most of the times we do have a complex requirement and we cannot achieve those complex requirements with the APIs provided by the Salesforce. So platform have provided the provision where we can also go and create our own API. For example, let's say, again, I'm taking a similar example, we do have two systems. One is the Salesforce and second is the Oracle. Right now, this time Oracle wants to invoke into the Salesforce either to get the data or to insert the data or to delete the record from the Salesforce. Right, and we cannot achieve that requirement with the help of the, let's assume that we cannot achieve that requirement with the help of the standard APIs provided by the Salesforce. So on this platform, we will see how we can go and create our own custom APIs. Okay, there are few considerations that we have to take care at the apex end before we go and create those APIs. So what are those considerations? The first consideration here is whenever we are creating the apex class to act as an API, the class must be global. Class must be global. Moreover, your methods that you are defining in the class, the method will be must be global as well as the static. The methods must be global as well as the static. Again, I'm repeating the first thing is your class must be global. Second thing is your methods must be global as well as the static. Moreover, we have to also add few annotations at the class level as well as at the method level. Moreover, we have to add the different annotations at the class level as well as at the method level. So at the class level, again, we discussed in our previous session, whenever we deal with the REST API, there are few resources that we have to provide. First resource is the endpoint. Second resource is the method. Again, I'm repeating, whenever we deal with the REST API, there are two things that are mandatory. First is the endpoint and second is the method. So here, with the help of this REST resource annotation, we go and define the endpoint. With this REST resource, what we'll do? We go and define the endpoint. So Oracle as a system, it has to invoke an API to the Salesforce, which API or which endpoint the Oracle will invoke. Oracle will invoke this standard endpoint first. First, HTTPS, whatever your instance name, followed by the slash services, followed by the slash OPEX REST. And after hitting this API, you have to tell them to go and look for the specific service. Let's say this service that I put in this diagram is the account service. So what the Oracle system have to do? Oracle system have to invoke HTTPS, followed by your instance, followed by the slash services, followed by the OPEX REST, followed by the endpoint that you have defined here. Now, the endpoint that you are putting here, this endpoint must be unique in your org. Again, I'm repeating, the endpoint that you are putting here, this endpoint must be unique in your org. If you do have multiple endpoints, you will get the unexpected behavior from the platform. If you do have the multiple endpoints with the same name, you will get the unexpected behavior from the platform. So this is the precaution that you have to take care whenever you are creating the API inside the Salesforce. You have to make sure that the endpoint must be unique in your org. Next thing is, we have to go and also define here the different annotations at the method level. We have to also go and define the different annotations at the method level. So at the method level, we do have different annotations, including the at the rate HTTP get, at the rate HTTP post, at the rate HTTP delete, at the rate HTTP push, put, and at the rate HTTP patch. We discussed in the list that when we discussed rest in the past, I discussed that whenever we deal with the rest, we do have the five different methods, that is the get method, host method, delete method, put method, as well as the patch method. So whenever we are creating the API in the Salesforce at the method level, we have to signify whether this method works with what rest method. So for example, here we have created this method that is get record and we have annotated this method with at the rate HTTP get. So whenever the Oracle system is hitting this endpoint and sending the request as get, then the framework will invoke this method. Again, I'm repeating with Oracle system hitting this endpoint and setting the method as get, then system will hit this endpoint. In case I am putting here at the rate HTTP post and in that scenario, if the Oracle system is setting something as the post and hitting this endpoint, then whatever the method that we have defined with at the rate HTTP post, that method will be invoke. Like this, we can go and create the multiple methods here with the multiple annotations. Like this, we can go and define here multiple methods with the multiple annotation. Now another key thing here is you cannot have more than one method with the same annotation. You cannot have more than one method with the same annotation. So what I mean to say here is you cannot have different get record methods with the same annotation. For example, let's say here you have defined two methods, get record one and the get record two. You cannot use the same annotation at the rate HTTP get. If you do something like that, you will get the compile time error. If you do something like that, you will get the compile time error. So let's go and see how we can go and create our own custom APIs. Okay, so I'm putting a demo now. So I'm navigating to one of my orgs with the full screen and I'm navigating to the developer org. Here we will go and create our own API. So to create my own API, I'm creating a new Apex class and let's say I am giving the name of the class as the account management. I am giving the name of the class as the account management. As I said, the first thing that we have to do here is we have to make sure that the class that we are putting here, the class will be global. So I'm changing the modifier of the class from public to global. Next thing is we have to also go and define the URL mapping to define the URL mapping here. We go and use the resource. And here we go and put the URL mapping URL mapping must be unique across your org. Let's say here I am putting the URL mapping as the account MGMT. You can give any name. I'm just giving this name as the account MGMT like this. I'm just giving the URL name here as the account MGMT. Whenever we go and define the URL mapping, we always start with the URL mapping with the forward slash. Right now here we go, we can go and define the different methods now. So let me go and define one method. Let's say my first method, it is fetching all the top revenue account from my org. So I am waiting one method. Let's say global static void. Let me return here the list of account not void list of account. And here I am putting the method name as the get top counts. What I am doing here is I'm putting the method name as the get top account. Now, here the next thing that I am doing here is I'm just putting here the list of account and putting here the account list and writing down the query to get the list of accounts which are the top accounts. So here I'm putting the select let's say ID, industry, rating, annual revenue. Right, comma, or let's say from account where annual revenue not equal to null ordered by descending annual revenue. Let's say limit. Right. So I have written this query. Let's go and validate whether this query is correct or not. It's always a good practice to validate the query before we actually go and use that in the API. So to validate the query again, I am using the query editor here. Standard tool provided by the sales force to validate the query. I'm just putting my query here and clicking on the execute. I'm getting some other account ID, industry, annual revenue from account ordered by annual revenue descending. Right. Now I am getting the list of records with the annual revenue. So this is my query is. I got one mistake in my query. I'm just correcting it. Order by annual revenue and putting a descending here. So this is my query and what I have to do. I just have to go and return those accounts. What I am doing here is I am returning those accounts which I had tried from the query. Now I want this query to be invoked whenever the user is sending the gate request. How I can make sure that this query to be invoked when the user is making the gate request. For that, I have to make sure that I am annotating this with the iterate HTTP. I have to make sure that I'm annotating this with the iterate HTTP. If you specify here the annotation at the iterate HTTP get when the user hit spend point and set the method as the get method. This method will be invoked. What this method is doing, this method is returning the top account available in my. Right. So I can test whether this API is working as expected or not as expected for the testing. We'll again use the postman. Again, I'm on the postman. First thing that I am doing here is I'm performing the author authentication one more time. So to do the authentication, I'm getting the new access token sending the request back. Again, I'm allowing it opening the postman. Click on proceed. Let me copy this instance URL and click on the use token. Again, I'm just going to the variables to check whether I am using the same instance variable or not because I am using this postman for the multiple projects. So yes, I am using the same instance URL. So no action will be required here. Right. Now let's go and validate our API to validate our API. What we are to do, we have to invoke an apex from the postman to do that. We do have a request here. That is the apex rest to have a request available here. That is the apex rest with the help of this request. What we can do, we can make the API call. Now again, here we have to go and first define which method we have to invoke. We have to invoke the get method because we have created a method here with the and with. I did it. I did it. Annotation. So I am sitting here. Method get. Next thing is I have to go and define the endpoint in endpoint. The ask here is to go and define the URL mapping as well. Right. Because here my URL, it is accepting the URL mapping. So what I have to do here is I have to go and put the URL mapping here. So this is my URL mapping. So I will go here and put the URL mapping here. Again, I am not taking the first slash here. The reason being my first slash is already available in my request. That's why I am directly using the account management followed by the slash. And let me go and click on set. Again, I'm getting the status as 200 and I'm getting this account from my art. I am getting all these accounts from my really simple request. What we have done. We have sent one request. Right. We got the data and we are just sending that data back to the party system. So when the Oracle will invoke this API, you just have to let the Oracle know this is the endpoint. This is the gate method. They will first perform the authentication, right? By using the OAuth or by their any by their any means, right? That I will cover how to perform the authentication in a while. But and this is how you go and accept the data. This is how they will go and accept that data. Right. Now, again, I have created a very simple one. Now, let's say my method is not my gate request is accepting a parameter because we discuss that in the gate method. What we can do. We can also pass the parameters in the URL. Now, let's say my gate method. It is accepting the parameters in the URL. Let's say I have to show the accounts based on the industry. So my get method is accepting a parameter. Let's say here as an industry and whatever the value that they are sending here in the industry. Accordingly, I have to filter my what I have to do accordingly. I have to go and filter my data. Now I'm taking one step further. Now, in this example, what I am doing here is my method is accepting the industry as energy. Now how I can go and modify my request now. Now here, my method is accepting the industry. How we can access the URL in your method. Now the question comes, whatever the URL that they are sending, how you can access the parameter value from the URL. To do that, you have to use the rest context class provided by the Salesforce. So how to do that, you have to use here the rest context dot request dot. It will this method, it will give you all the parameters in the form of map. This method, it will give you all the parameters in the form of map. Let's say my map here is of type string of type string. Let's say I'm giving the name to this one as a params map. So what I am doing here is to accept all the parameters from the URL. I'm using the rest context dot request dot parameters. It will return me all the parameters available in my URL. And it will return in the form of map where the key will be the industry and the value will be the energy. Where the key will be the industry and the value will be the energy. So I'm accepting all those parameters. Now what key I'm looking for, I'm looking for the key here called industry. So let me go and put here string ACC industry is equal to I hope you guys already know how to access the values from the map. To access the values from the map, we use the dot get method. And in the dot get method, we have to pass the values from the map to access the values from the map. I hope you guys already know how to access the values from the map. To access the values from the map, we use the dot get method. And in the dot get method, we have to pass the key that we are expecting. So here we are expecting the key as the industry here. I'm expecting the key as the industry. So whatever the industry that has been passed, I am getting that value of that industry from this map. Let's go and add this industry again in the where condition so that we can only return those records that belong to the industry. So here I go and add industry is equal to I'm using the binding variable and passing the industry here and saving my changes. What I am doing here is I'm passing whatever the industry that I am passing and accessing that industry here. And after that I have modified my query at the industry because now I have to filter the records that is on the industry. So I go and again click on the send now. You can see here we are getting only those records which belongs to the industry as energy, which we are getting only those records which are the industry as energy. If I send any other industry for example here, let's say I am sending here the industry as banking and clicking on send. In case there are no records, we are getting the empty string. In case there are no records, we are getting the empty string. Let me check if we do have the records for the apparel. Now we do not have a record for the apparel as well. Whatever the industry records are available, you will get those records from the response form. For the energy, we do have the record. So we are getting this record here. Now let's say let me take one step further in the complexity now. Let's go and explicitly take interest because in the most times we do have to deal with that kind of scenario. Let's say here my business is not asking only for the account. They are asking for the related contacts as well along with those accounts. They are asking for the related cases as well for that account. They are not only asking for the account but they are also asking for the related, but they are also asking for the related contacts or the related cases. In such scenarios what we do whenever we have to send more than one data because here I am directly sending the flip-stop account. So it is very simple. Let's say I have to go and send the different types of data. In such scenarios, we take the help of the wrapper classes. In such scenarios, what we do? We go and take the help of the wrapper classes. So let's say I am defining another class here which is nothing but a wrapper class. So here I am putting account class, account wrapper. To send the complex data, I am just using the wrapper class here. And in the wrapper class, I am passing all those data. Let's say I have to send here the list of account. Let's say I am putting here the account list. I have to also send the list of contacts. So let's say I am putting here the con list. I have to also send here the list of cases. So I am putting here the case list as well. Now this time I am sending the complex data and I am sending the data in the form of wrapper. What I am doing here is I am sending this data in the form of wrapper. So how we can do that? To do that, what I am doing here is let me go and get all the account IDs from here. So to get all the account IDs, I am just iterating over this data. Either you can go and store this one into the collection, but let me keep it simple for now. You can also store it into the map collection and directly get the account ID. But let me keep it simple for now considering the target audience and I am iterating over this data one after the other. And I am storing this into the one set variable. That is the ID and I am naming that as account ID. That is equal to new set of ID. Now in this account ID set, I am adding all the account IDs. I see it out. Again, you can also use the relationship queries here to get that data. But for the demo purpose, I am just doing some additional things because I want to show you how to send the wrapper. Definitely you can use the relationship queries and send the data in the form of list of account as well. For the demo purpose, I am just using the wrapper classes and sending the data in the form of wrapper. So let's say here I am putting another list of contact. That is the con list and here I am putting the select. Let's say ID, last name, first name, email from contact where account ID in the whatever the account ID that we do have in the set. So where is that set variable? Account ID set variable. I am sending here the contacts also. Similarly, I am also getting the list of case here. So let me put here the case list. I am putting the different variables for the case list. Let's say priority subject. Okay, let me put only two for the cases from case where the account ID in the account ID set. Now how do I go? I do have these two things ready. Now let's go and share all this data in the form of wrapper. I have already created the wrapper. So here I go and initialize my wrapper. Account wrapper is equal to new of account wrapper. In this account wrapper, I am populating all these different fields that I have to send. So I have to send the account list which is available in the account list. Another thing that I have to send here is the contact list. So here I go and put the account wrapper dot contact list which is available in the contact list. And the last one I have also sending the case list here is equal to the case list. So I have populated all the required fields and both that what I am doing here is I am sending this wrapper here. So let me go and send the wrapper or a list of account wrapper. So what I am sending here is the complex data back to my API because no standard API is providing this functionality. All the standard APIs, they are either returning the one single object but most of the times we have to return the complex objects in the one single request and this is how we can do it by helping the, by taking the concept of wrapper. So let me check what is the error that we are getting. I didn't get the error. The error says that illegal conversion from account management to account wrapper to list. Account wrapper is equal to no account wrapper. Account wrapper dot list is equal to list. Just check the return type of this map. Okay, sorry. Yeah, it is list. Yeah. It's a list. So let me take out the list from here and hit the control S. Let's go and validate this output one more time. So in this example, what is happening? Multiple complex things we are getting the industry. That is the first thing and we are returning the complex data as well. So again, I am sending the same request. Click on send. You can see this time we are getting the contact list. We are getting the case list for that contact for that account and also we are getting the account list as well. So we are sending the kind of a complex data from the sales force back to the third party system. This is how you go and use the iterate get method to deal with the simple data as well as to deal with the complex data. Let me take one step further. Let me take one step further and we'll talk about the another request where we have to specify the body. As of now we are dealing with the gate. In the gate, it does not have to specify anybody, but we do have another request where we have to specify the body. Let's say I do have another request that is the iterate HTTP post and here I am putting the method name global static. Let's say for the time being I am putting other void and here I am putting the method name as create what this method is doing. This method is creating the account based on the different input that we are getting. Let's say here I am expecting the account name. I am expecting the account rating. Let's say I am expecting the account. Whatever the parameters that you are expecting, you just go and define all those parameters here. You just go and define all those parameters here. What you have to do? You have to go and create the account. Here I am just initializing the account. Account ACC is equal to new account. Suppose that I am populating all the parameters here. I am populating the account name which is nothing but this ACC name. Similarly, ACC dot rating is equal to ACC rating. Here I am putting the ACC dot industry. That is the ACC dot industry and here I am putting the account industry. What I have done? I have initialized the account, populated all those values that I am getting in the form of parameter. Populated all those values that I got in the form of parameter. Now let's go and create that account. Again I am using the try catch block. Here I am putting the insert ACC. Here let's say I am returning one message that is account created successfully. Account created successfully. Another thing that I am adding here is the catch block against the try block. Here what I am returning here is the error message. In case something has been failed, then I am returning the error message here by using the catch. Let me handle that exception. I am handling it as a parent exception. That is the exception EX. Here I put the EL dot and get message. Again I am getting one error void method. Let me just change the return type here too. I have created one method. It's a post method. What this method is doing? This method will be creating the account. How to do that? Again this time you will go and put here the method as post because you have to invoke this method. You have to state the method as post. Next thing is again no URLs are required. You can definitely take out that URL value from here. I am just taking out the value from here. Whatever the URL mapping that I do have, it's already available. Next thing that I have to go and specify here the body. Because whenever we deal with the post method, we do have to specify the body here. Here I am putting the body. In the body, you have to make sure that whatever the parameter that you are accepting, whatever the parameters that you are accepting, you have to go and define the body with the same name. You have to go and define the key with the same name. I am accepting the first parameter as the account name. Sequence doesn't matter. The name does matter. So I have to go and put here account name and whatever the name that you have to pass. Let's say I am putting the name here as account created for rest service. Account created for the rest service. The next thing that I have to pass here is the account rating. So I am populating here the account rating. Let's say account rating that I am populating here as the heart. Another thing that I am populating here is the industry. Let's say I am populating here is the account industry. And here I go and put the industry as energy. So I have populated all the required parameters that my method is accepting. And after that I go and click on the same. Let's go and check whether the record is created successfully or not. You can see here I am getting the message as account created successfully. This is the message that we have sent. Account created successfully. After the account has been created. So we are getting the same message here. We can also go to the org and validate whether the account is created or not. You can see here account created from the rest service. You can see here account is created from the rest service. What all the parameters that we have passed? We have passed the rating as heart. We have passed the industry as energy. All these values are initialized here. So again this is a very simple one. Let me take a bit complex one now. So here let's say we are getting the multiple parameters here. But let's say the business wants to send the complex data where they want to send the data to create the account as well as to create the contact where they want to send the data to create the accounts as well as to create the account. That data can be a simple object or that data can be a complex object as well. How you will go and deal with that type of scenario. To do that, what we have to do again here is we have to take the help of the wrapper class. To do that, what we have to do here is we have to take the help of the wrapper class. So here again I will go and create the wrapper class with the complex data. Let's say the kind of a data that I am expecting in my wrapper class is the account record as well as the contact record. So here I will go and put global class and here I will put the account information. Here I will go and put the account information. Let's say I am putting this as a global account. Let's say I am putting the name as an account record. And in this variable some third party system will go and set the value. I will also go and define the getters and setters. How we go and define the getters and setters in the app by using the get slash set. Similarly, here again I go and put the global contact and here I am putting the contact record and for this also I will go and define the getters as well as the setters. For that also what I am doing here is I am defining here the getters as well as the setters because some third party system will go and set the value that is the reason here I am defining the getters and the setters for that. Whenever I am expecting the information I am expecting the information in this form. So let me go and I am just commenting this one for now and I will go and create another method which will be bit complex. So we have understood the simple one I am taking another example for the complex one now. So here I go and put global static let's say create account and contact. For the timing I am putting the return type as void again and this method it is accepting the account information where I do have the complex information where I do have the complex information. So let's say here I go and put account ACC record because this information it is of type account record which is of type contact and contact record which is of type contact. So I can directly access this. So here I will go and put information dot what is the property account record is the property. So here I go and put the account record. Similarly contact what is the property on the record information dot the property name here is the contact record where is that contact now again I got the information here for the account as well as the contact which is type of a complex information so in a single request we are getting both these details I have initialized this to the account and also I have initialized this to the contact again I am using the I catch block so again I am at first I will go and insert the account record after that what I am doing here is to this contact record let's say I have to link this to the account so I am populating the account ID that we have created let's say ACC record dot ID right and after that I will go and perform the insert operation on the contact record as well right after that what I am doing here is I am inserting the contact record as well was that let me go and return the message here as account and contact created successful here also you can send the wrapper complex data right but we already covered that example that's why I am keeping it simple for now and here let's say I am handling the exception ex and here I am sending the error message return ex dot get message let me go and say this and here I am adding the return type as the string let me go and say this and check if we are getting any error no we are good it is so what we are expecting here kind of a complex information we are setting this complex information and creating the account as well as we are creating the contacts as well so let's go and test this functionality as well the key thing here is how we go and create the payload for the testing so pay close attention how I am creating the payload for the testing here right again I will go to the property and this time I have to go and create the complex payroll so whenever we are sending the data here we are sending the data in the JSON form so what is the parameter that my method is accepting information so here I go and put the information what is the parameter my method is accepting information so I have put here the information now this information have the two different complex objects this information have the two different complex objects one is the account record so here I go and put the account record another one that we do have here is the contact record another one that I do have here is the contact record so we do have the account record as well as the contact record as the complex object in the account record let's say I am populating the fields here as the name here name as the let's say create complex account with rest service you can give any name I am just giving this name right and yeah sorry I also everything must be in the code so here I am putting this inside the codes and I am also putting this inside the codes too putting a comma adding another property let's say I am adding here the industry now let me put here the industry as energy and adding another property let's say account sorry let's say rating as similarly I have to also go and populate the contact details so let's say I am putting here the last name as the test contact from rest service putting everything inside the codes followed by I am also putting the first name let's say I am putting the first name here as the test right another thing that I am putting here here let's say as the email at the redtest.com right so let's say this is the complex data that we have to send from one system to another system again this one also needs to be in the code so here also I am putting this one inside the codes too and account record is also inside the code so this is the kind of a complex data that we have created where my method is accepting the information right information I can use of type account information it does have the two object account record as well as the contact record that's why I have done account record as well as the contact record I have put three different parameters here that needs to be process let's go and click on the send now and you will check whether the account and the contacts are created successfully or not you can see here that we are getting the message account and contact created successfully let's go and validate the orc whether the records are created successfully or not so again I am inside the orc this is the record that we have created create complex account with the service right and here we do have the details that is the rating as hot and industry as energy also we have created one related contact with this you can see the related contact is also available with the first name last name as well as the email now the advantage with this example is here you can pass any number of fields in the previous one you can only pass the limited number of fields but in this example you can go and pass any number of fields this is how you can go and create the complex APIs with the help of the this is how you can go and create the complex APIs with the help of the the rest of the method is going to be exactly same according to your usage you can go and define the different types of annotations like we have covered the get we have covered the post let me take one more quickly that is the delete which we can use to delete the record as well similarly you can use the patch to update the record and put to perform the absurd operation as well let's say I have to go and delete the record so to delete the record again we have to follow the similar analogy right what we have done we have to get the value from the URL and perform the operation you will see it's a repeated task that we have already done but let me show you quickly how we can delete the record so again I am putting here the global static let's say I am putting here a string and the putting the method name as the delete account and here my method is accepting a parameter let's say string as the account id so my method is accepting a parameter here as the string as the let's say my method will accept the value from the URL it is not accepting any parameter because delete method again it will not accept any parameters it will take the value from the URL how to take the value from the URL we already discussed that we have to use this one risk contest.request.params and from here we can access the values from the URL so again here also I am doing the same thing I am just hoping this and putting it here to accept the value from the URL now in the params map this time I will pass the id so here I am checking back paramsmaps.get and let me put here the ccid and here I go and put the string of account id is equal to whatever the value that we are getting I am storing the value in this variable and for that I am just performing the delete operation let me go and do that list of account account list select id from account where id is equal to this id right the practice that we generally follow whenever we are dealing whenever we have to select the record so I am again selecting the record here I am checking that if account list is not empty in case the account list is not empty and we are getting that record then within the try catch block I will go and perform the delete operation here so here I am deleting the account list here I am deleting the account list and in the case of exception also I am handling the exception let me go and put here exception ex here I am returning the message ex.get message and in the case of successful I am returning the message as record created successfully in the case of successful I am returning the message as record created successfully let's go and check whether we are getting any error missing return statement return type is string ok in case the condition is not satisfied then I am just putting the return statement as record not found in case the condition is missing in case we are not getting the record then I am just returning the message as record not found let's go and test this behavior too this time we have to pass the account id so here I go and pass that account id so this time again I am setting the method this time as the delete method in the delete method body does not make sense so I am just removing the body from here going to the parameters here I am defining the parameter parameter that I am expecting for the delete one is account id and what is the id what is the value that we have to pass let me take this value from the environment and pass that id here this is the account id let's say that I have to pass and here I go and pass that id let's go and check now the delete operation is set we have populated the we have populated the account id here our URL mapping is also set let's go and click on send now you can see here we are getting the message that record deleted successfully if we go and try to refresh this page now the expectation here is we should not get that record so today basically what we have covered is how we can create a simple rest service moreover we have also seen how we can cover the complex rest services as well by using the concept of the wrapper classes let me go and check in case there are any questions today now guys please put your questions in the chat box I started taking the questions now Ganesh if you are getting the error that session is expired you have to again go and authenticate I hope you followed me today today again my session got expired because I logged in after the few days so I have to go and authorize it one more time to create the bulk API for custom object Archana asked the question do we have to create the bulk API bulk upload from the external services or source create API from the custom object as well Archana the answer again depends on the business scenario if business wants to do this in the synchronous way right if you guys can recall whenever we talked about the integration we talked about the timings the timing can be a synchronous or the asynchronous the business wants to implement this in the synchronous way then you have to do this with the help of rest service in case business is completely fine to do this in the asynchronous way definitely bulk API will be the good option to explore Archana another question is can we create the multiple gatepost method under the same rest resource no you can only create one method with the same annotation at a time in a one single class when I ask the question can we call any apex class or the batch class from the rest resource any apex class yes batch class when I ever tried it I need to explore that if we can invoke the batch class from the rest resource but definitely you can invoke another apex class by creating the instance that's completely fine Archana again that's a completely architect question based on the systems Archana ask the question how to achieve the schedule migration of bulk data from the external system to custom object Archana it's completely an architect question to answer this question I have to understand the source system and the target system and then I'll be in a position to answer this again there are multiple things that we have to take care apart from deciding the bulk API or the rest resource how to debug the issues related to the governor limits error to debug the issues for the governor limit Archana you can use the limits class self-force have provided the limits class you can definitely explore that class you will get a number of examples over the Salesforce community as well how to use the limits class provided by the Salesforce if by keeping the track of that limits class methods you can figure it out whether you are about to hit the governor limits or not moreover to debug the things you can also go over the logs in the log section we do have a section where Salesforce do list all the governor limit that you have invoked in one single transaction Archana I already answered your another question we cannot have multiple get post methods in the single response class you have to go and create the separate rest classes and have the separate get post accordingly I believe I have repeated the wrapper class two or three times let me know if you still have any questions on the wrapper class wrapper class are nothing but a subclass that we use to send different types of data back to the as an API response or moreover we also use the wrapper class to send the complex type of data to the LWC component or to the visual force pages as well yes Rajesh you can also use the parent to child relationship to bring the cases and the contacts under the account yes you are correct if Oracle is sending the million data then we will not go with this approach we will go and explore another approach that is the bulk API where we ask them to share the data in the form of CSV so that you can go and perform the operations by introducing the bulk API or you can take the help of the admin team to upload the data from the data loader this solution is not for the bulk API this solution is for the more real time scenario where you are getting one single record from the Oracle and or you are getting one single request from the Oracle and you have to process that request yes Sunil this is what what we have discussed today it's completely an inbound integration where we are getting the request from the third party system and sending the response back to the third party system so just you are correct this is a complete example of the inbound integration so we will discuss how to do outbound integration where what we will do is whatever the rest API that we have created today today we will go and call that API from the another Salesforce org moreover if the time permits I will also show you how we can do the integration with the LinkedIn as well if you want to delete the more account records then definitely you have to go and compute a wrapper class accept all the inputs whatever you have to perform the delete operation and then do the delete can third party system send attachment like PDF and image how to add in your SFDC org yes Sunil third part again that is not the rest API is not the correct way to deal with it we do have another API to explore in case you are dealing with the bulk amount of data like the PDF or the image rest API is not designed for that purpose province Ganesh you have to explore about that error I have never encountered this error invalid header in the header content attachment insert from the third party system again there are multiple APIs that you can explore to get the third part to get the attachments from the third party system yeah that's all from today's session I hope today's session is helpful to you folks where you have understood the different concepts about the rest service I have not only focused on the very basic one but I also try to cover the complex scenarios as well by using the concept of the wrapper classes too I hope today's session will make some sense to you and it have added some learning in your Salesforce knowledge