SFDC Stop - Always the latest about Salesforce


Full Tutorial Series with videos, free apps, live sessions, salesforce consulting and much more.


Telegram logo   Join our Telegram Channel

Sunday, 3 November 2019

Salesforce Integration Tutorial Part 1 - Introduction and Setting up Workbench

Hello Trailblazers,

Previously, we learned:- How to connect to Salesforce with Postman. If you open postman, you'll see there are a different types of requests that we can make to an endpoint as shown below:-


Out of all these request types, our custom API will support the 5 types of requests that are highlighted in red above and those are:-

  1. GET:- Used to query/retrieve records. We don't have any request body in this case. We send the information required to retrieve data in the URL parameters.
  2. POST:- Used to create new records. In this case, we send data to the server in the request body. This is more secure as compared to GET as we don't expose any data in the URL parameters. We send our data in the request body instead. We usually perform the insert operation on the data in this case.
  3. PUT:- Used to update the existing records or create new records. It is usually specified to perform the upsert operation in which if a record id is specified in the data we're sending, it'll update that record with the new data specified in the request body, otherwise, it'll create a new record.
  4. PATCH:- Used to update fields in the existing records. In this case, we usually perform the update operation on the data given. So, the data must have a record id for the operation to be successful.
  5. DELETE:- Used to delete a record using the record id. We mainly require only the unique record id in this case which will be used to delete the record. No other information is required.

While each of the request type has it's own significance, the most commonly used are GET and POST.

Before moving ahead, I'll recommend you to go through:- How to connect to Salesforce with Postman tutorial if you want to learn how authentication actually works. I have connected my Salesforce Org with Postman and shown an example of hitting a standard Salesforce API. Once you're aware of the connectivity stuff, you can easily test the rest APIs that we're going to create. As an alternative you can also use the workbench tool which is available at:- https://workbench.developerforce.com.

To use workbench, follow the below steps:-

1. Go to https://workbench.developerforce.com and you'll see the below screen:-

2. From the environment dropdown, choose your desired environment. For developer/production orgs:- choose production and for sandboxes, choose sandbox.

3. Choose the desired API version (I usually choose the latest one) and check the checkbox saying I agree to the terms of service.

4. Finally, click on the Login with Salesforce button and you'll see the below login screen:-


5. Enter your credentials, and click on Log In. If you're using it for the first time, you'll see the below screen requesting authorization.


6. Click Allow and you'll be redirected to the below screen:-

7. From the menu above, hover over utilities and click on REST Explorer. You'll see the below screen:-

8. This is our REST API explorer and to test it out I'll use the standard API and will query the accounts present in my org. In the textbox as shown in the image above, replace the text to:- /services/data/v47.0/query/?q=SELECT+Name,Type+FROM+Account and click on Execute button.

9. As you can see in the above image, I have used the standard Salesforce Query API to query name and type of all the accounts present in my org and the result is returned to me as a response. You can also click on Show Raw Response below the textbox to see the raw response. The raw response is the actual JSON response body which we see in postman or in other system when we hit this API. The raw response of our query is given below:-


In this tutorial, you learned about the basic request types and we connected workbench tool with our salesforce org. Now, we're all set to start working on custom REST APIs and we'll be using workbench to test those APIs. We'll be using workbench because in this case, we don't need to set the access token in the header while hitting salesforce APIs as workbench does that automatically for us.

Now, it's your time to explore the standard REST APIs available using workbench. Also, have a look at the REST API Developer Guide for more information on the standard REST APIs. In the next tutorial, we'll be creating a custom API and explore the GET request type in detail.

Tired of reading or just scrolled down, don't worry, you can watch the video too.



If you liked this tutorial, make sure to share it in your network and let me know your feedback in the comments section down below.

Happy Trailblazing..!!

7 comments:

  1. Hello Rahul
    I read and implemented your blogs on Aura Lightning component basics and Lightning Events. I really liked them and got to learn a lot from it. So first of all thanks for those blogs and keep it up .

    Secondly I would like if you can prepare some content about integration of wordpress data and salesforce object using REST API.

    ReplyDelete
    Replies
    1. Hi,

      I'll be adding blogs in continuation of this one for Salesforce Integration with 3rd party systems. I am not aware if wordpress is having any predefined tool for easy integration with salesforce but if there is a custom stuff that requires code, then the tutorials will surely help. Even with a tool, you must have a rest api in Salesforce if you want to perform some custom action according to your requirement and the series will focus on that only. I'll have a look on the wordpress stuff and add another blog if possible. Please add your request here:- https://www.sfdcstop.com/p/what-do-you-want-us-to-post-next.html so that I can keep a track of the same. And thanks for following up with the lightning tutorials, I am glad it helped :-)


      Delete
    2. Ok Rahul, I posted a request on https://www.sfdcstop.com/p/what-do-you-want-us-to-post-next.html for wordpress salesforce integration.
      Basically I want learn how to integrate custom salesforce object records with wordpress data. Zapier is one of the option that I found. Wanted to achieve it using some custom code and actually I don't know in detail about how wordpress works.

      Delete
  2. Thanks mate! Great tutorial, keep up the great work.

    ReplyDelete
    Replies
    1. Happy to know that you liked it Walid :-) Make sure to share it in your network too..!!

      Delete
  3. Hi Rahul,
    I'm working on a project to integrate TSheets with Salesforce. They have published their API documentation on Github with easy access to import into Postman. Perhaps this could be an easy one for users to start with since you already recommend Postman. I would be particularly interested in this.

    ReplyDelete
    Replies
    1. That's great. I think in that case you should also have a look at the callout framework:- https://www.sfdcstop.com/2019/12/httpcalloutframework-light-weight.html as you'll be making callouts from salesforce to Tsheets

      Delete