Step By Step Guide To Getting Started with Salesforce REST API using Java In VS Code
How do you connect to Salesforce from an external application, say, for example, Java? If you Google for the information, you will quickly learn that Salesforce provides different methods and different APIs. But what you will probably not find is a step-by-step guide teaching you exactly how to do it. In this blog post, I have stitched together complete step-by-step instructions with screenshots on how to download, install, configure, and use Salesforce REST API to connect from a Java program and execute some basic transactions (query, insert, update, delete records). In less than 45 minutes, you will have a fully functional Java program that will connect to Salesforce and execute transactions in Salesforce.
The guide includes downloading and installing necessary HttpClient and JSON frameworks that are required to work with Salesforce REST APIs. This is followed by referencing the JAR file in your Java program, logging on to Salesforce from the Java program, querying and manipulating data. Here is an overview of steps that need to be completed and are covered in the guide.
Install Visual Studio Code
Install Java
Install HTTP Client
Install JSON Framework
Create Connected App in Salesforce
Prepare VS Code for Executing Java Program
Prepare Java Environment for REST API Execution
Test Connecting to Salesforce from Java
Execute Transactions From Java Using REST API
Even if you are not a developer, you should be able to follow the guide and have a working Java program at the end of it. Sounds interesting? Download the following presentation and let’s get started…
Here is the URL to get the code used in this guide.
Not only this, you can go a step further and use other RESTful APIs that Salesforce provides to extract and manipulate data and metadata. For a list of different APIs along with a brief explanation on which API should be used when, please navigate to the URL https://help.salesforce.com/HTViewHelpDoc?id=integrate_what_is_api.htm.
References & Useful URLs
Salesforce REST API Developer Guide – https://www.salesforce.com/us/developer/docs/api_rest/
(Note: This step-by-step guide is created based on my earlier blog post #Step-By-Step Guide to Get Started with Salesforce REST API using Java, which showed how to execute a Java program in Eclipse. In this guide, I have replaced Eclipse with VS Code as Salesforce has discontinued its Force.com IDE in Eclipse and now recommends that developers use VS Code with “Salesforce Extension Pack”.)