Step-By-Step DIY Guide: To Salesforce For
Step-By-Step DIY Guide: To Salesforce For
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 1
Using This Guide
A couple of standards/conventions have been followed in this guide.
Here is what they mean
Important information. Take a closer look and follow as
Text with Red Background advised. You may not be able to complete the exercise
successfully if you miss these instructions
1. Text with White background, red Actions that you need to follow to configure. Carry out these
border and a number. In a callout
format
steps in the order of its sequence number.
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 3
Related Blog
If you haven’t already, please navigate to the following blog post URL
before starting with this guide. The post contains useful information
and links to relevant resources including the option to download the
PDF copy of the presentation
http://www.asagarwal.com/a-60-minutes-step-by-step-diy-guide-to-sales
force-rest-api-for-non-developers
Visit Visit
asagarwal.com for
asagarwal.com foruseful tipsand
useful tips andtricks
tricks on Salesforce
on Salesforce 4
Ingredients
■ Salesforce Developer Edition / Enterprise Edition or above. Your
Salesforce Edition must allow the API Access. Your can sign up for
a FREE Salesforce Developer Edition at URL
https://developer.salesforce.com/
■ Google Chrome
■ Internet connection
■ Vodka with ice, lemon & a pinch of salt celebrate your learning. :-)
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 5
Steps Overview
➡ Create Connected Apps in Salesforce
■ Install Advanced REST Client in Google Chrome
■ Connect to Salesforce from Advanced REST Client
■ Query Records in Salesforce using REST API
■ Create Record in Salesforce using REST API
■ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 6
Login To Salesforce
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 7
Get Your Security Token
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 8
Get Your Security Token
1. Click on Personal
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 9
Get Your Security Token
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 10
Get Your Security Token
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 11
Get Your Security Token
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 12
Create Connected Apps
1. Back in Salesforce,
Click on Setup
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 13
Create Connected Apps
2. Click New
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 14
Create Connected Apps
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 15
Create Connected Apps
1. Check Enable OAuth Settings
4. Click Save
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 16
Create Connected Apps
1. Click Continue
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 17
Create Connected Apps
2. Click on Manage
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 19
Grant Permission to User’s Profile
1. Click Edit
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 20
Grant Permission to User’s Profile
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 21
Grant Permission to User’s Profile
1. Click OK
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 22
Grant Permission to User’s Profile
1. Click Save
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 23
Grant Permission to User’s Profile
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 24
Grant Permission to User’s Profile
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 25
Grant Permission to User’s Profile
2. Click Save
1. Ensure that the profile of the user with which you want to
connect using REST API has the ‘API Enabled’ permission
checked. If you are connecting with the user whose profile is
‘System Administrator’, this is checked by default
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 27
Steps Overview
✓ Create Connected Apps in Salesforce
➡ Install Advanced REST Client in Google Chrome
■ Connect to Salesforce from Advanced REST Client
■ Query Records in Salesforce using REST API
■ Create Record in Salesforce using REST API
■ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 28
Install Advanced REST Client
1. Open Google Chrome and click on
‘Customize and control Google Chrome’
icon
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 29
Install Advanced REST Client
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 30
Install Advanced REST Client
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 31
Install Advanced REST Client
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 32
Install Advanced REST Client
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 33
Install Advanced REST Client
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 34
Install Advanced REST Client
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 35
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
➡ Connect to Salesforce from Advanced REST Client
■ Query Records in Salesforce using REST API
■ Create Record in Salesforce using REST API
■ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 36
Connecting to Salesforce from REST Client
To connect to Salesforce from Advanced REST API Client, you need to
prepare the connection string as per following format
https://login.salesforce.com/services/oauth2/token?grant_type=p
assword&client_id=<client_id>&client_secret=<client_secret>&use
rname=<username>&password=<password><security_token>
1. Use login.salesforce.com if you are connecting to production or developer edition org. Use
test.salesforce.com if you want to connect to Sandbox.
2. Replace <client_id> with Consumer key copied in previous steps
3. Replace <client_secret> with Consumer Secret copied in previous steps
4. Replace <username> with your Salesforce Username
5. Replace <password> with your Salesforce password. Append the security token if applicable
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 37
Connecting to Salesforce from REST Client
So your final connection string should like something like this
https://login.salesforce.com/services/oauth2/token?grant_type=p
assword&client_id=3BRG9rKhT8ocoxGlaFYGe98k75x5bSs1_f2tFh.EM7Ppv
DCu.d_wubQWT0yPLUlit0599q.1Bz8Ud_2Ujkf9Z&client_secret=47234524
3512440999&username=ashish@asagarwal.com&password=ilovesalesfor
ceiAb1J1diHc8DSVle9dTZJ4Q0e
No, Don’t try to connect using the above string. These are not the
actual values of my Salesforce Org. :-)
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 38
Connecting to Salesforce from REST Client
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 40
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
➡ Query Records in Salesforce using REST API
■ Create Record in Salesforce using REST API
■ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 41
Execute Query through REST API
Now that you are connected, you can execute a SOQL Query in
Salesforce through REST API. The URI for the REST Query is
https://<instance_url>/services/data/v35.0/query?q=<SOQL Query>
1. Use the value of instance_url returned in the response of the login call
2. v35.0 - This will be the API version. This changes with every new release of
Salesforce. For example for Winter 16 release of Salesforce, the API version is
35.0
3. SOQL Query that you want to execute
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 42
Execute Query through REST API
1. To execute a query in Salesorce using REST API, specify the URI, i.e.
https://<instance_url>/services/data/v35.0/query?q=<SOQL Query>
where you replace the value of the instance URL with the value returned as response from the login call
2. Select the
HTTP method
to GET
3. Set the Header of the REST API Call to “ Authorization: Bearer <access_token> “ 4. Click Send
where the value of the access token is the value returned in the response of the login
call
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 43
Execute Query through REST API
1. Alternatively, you can click on the ‘Form’ tab for HTTP Headers and specify the
Header and its value separately 2. Click Send
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 44
Execute Query through REST API
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 45
Review Steps
Now that you have executed a simple REST API call, let’s do a quick recap of
steps
■ Connect to Salesforce and get an Access Token
■ Make REST Calls specifying
■ The Resource URI (stands for Uniform Resource Identifier)
■ The HTTP Method (e.g. GET, POST, PATCH etc.)
■ The Request Headers (e.g. Access Token)
■ Review Response
■ The Status Code (200 denotes all OK)
■ The response Body (by default is returned in JSON format)
Once you have response returned by the API, you can process the response in
whatever way you want. E.g. if you are using Java to make API calls, use Java
libraries and methods to process the JSON response returned by the API
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 46
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
➡ Create Record in Salesforce using REST API
■ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 47
Creating Record through REST API
1. To create a record in Salesorce using REST API, specify the URI, i.e.
https://<instance_url>/services/data/v35.0/sobjects/<Object API Name>
2. Select the
HTTP method to
POST
4. Since we are creating a record here, we need to specify the values for the fields in Account
object in JSON format (this is known as PAYLOAD). In the PAYLOAD section, select ‘Raw’ tab 5. Click Send
and enter the values as shown here. The value is entered in format of
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 48
Creating Record through REST API
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 49
Creating Record through REST API
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 50
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
✓ Create Record in Salesforce using REST API
➡ Update Record in Salesforce using REST API
■ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 51
Updating Record through REST API
1. Oops ! I made a mistake. I forgot to specify the Billing City & Phone for the Account I just created. Let’s correct it. To
update a record in Salesorce using REST API, specify the URI, i.e.
https://<instance_url>/services/data/v35.0/sobjects/<Object API Name>/<Salesforce Record Id>
2. Select the
HTTP method to
PATCH
4. To update the record, follow the same method as Create. Specify the fields and their values
5. Click Send
in the Payload in JSON format. In the PAYLOAD section, select ‘Raw’ tab and enter the values
as shown here. The value is entered in format of
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 52
Updating Record through REST API
1. And the status code that you will receive this time is 204.
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 53
Updating Record through REST API
1. You are still not believing me. Come on. Refresh your
Account tab in Salesforce and see it for yourself.
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 54
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
✓ Create Record in Salesforce using REST API
✓ Update Record in Salesforce using REST API
➡ Delete Record in Salesforce using REST API
■ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 55
Deleting Record through REST API
1. Ok, let’s complete the cycle. Now, we will delete the record we just created. To delete a record in Salesforce using
REST API, specify the URI, i.e.
https://<instance_url>/services/data/v35.0/sobjects/<Object API Name>/<Salesforce Record Id>
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 56
Deleting Record through REST API
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 57
Deleting Record through REST API
Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 58
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
✓ Create Record in Salesforce using REST API
✓ Update Record in Salesforce using REST API
✓ Delete Record in Salesforce using REST API
➡ Other REST API Calls
■ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 59
Other REST API Calls
1. To get a list of all the objects in your Salesforce instance use the URI
https://<instance_url>/services/data/v35.0/sobjects/
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 60
Other REST API Calls
1. And in response you will get a list of all the SObjects and its details in
your Salesforce Instance.
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 61
Other REST API Calls
1. To get a list of all the child relationships and fields in an object use
the URI
https://<instance_url>/services/data/v35.0/sobjects/<Object
Name>/describe
4. Click Send
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 62
Other REST API Calls
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 63
Other REST API Calls
1. To get a list of all the field values on a particular record use the URI
https://<instance_url>/services/data/v35.0/sobjects/<Object Name>/<Salesforce Record Id>
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 64
Other REST API Calls
1. And in response you will get a list of all the fields and its
values for the specified record id.
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 65
Additional Reading
■ In previous slides, we have seen a few useful URIs and the
functionality that they provide.
■ There are many other URIs that Salesforce REST API provides.
Refer to Salesforce REST API Developer Guide at the following
URL to learn more about these URIs
■ https://resources.docs.salesforce.com/sfdc/pdf/api_rest.pdf
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 66
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
✓ Create Record in Salesforce using REST API
✓ Update Record in Salesforce using REST API
✓ Delete Record in Salesforce using REST API
✓ Other REST API Calls
➡ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 67
Extra Bytes
Hopefully these examples give you a pretty good idea on how to use
the Salesforce REST API. Now let’s take a look at
■ Some of the other things that REST API supports
■ Useful features of “Advanced REST Client” (ARC) Google Chrome
extension that we are using
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 68
Getting Response in XML Format
To get the response in XML format, all you need to do is to set the Request Header to
Accept application/xml
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 70
Sending Payload in XML Format
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 72
Useful Information - Supported HTTP Methods
Salesforce REST API supports the following HTTP Methods
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 73
Useful Information - Status Codes
■ To view a list of different status codes that Salesforce REST API
returns, please refer to the following URL
■ https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_re
st/errorcodes.htm
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 74
ARC Features - Save
1. You can save your REST API Call details for future
use. In ARC click on ‘Save’
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 75
ARC Features - Save
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 76
ARC Features - Open
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 77
ARC Features - Open
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 78
ARC Features - History
ARC in Chrome on Mac Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 79
Steps Overview
✓ Create Connected Apps in Salesforce
✓ Install Advanced REST Client in Google Chrome
✓ Connect to Salesforce from Advanced REST Client
✓ Query Records in Salesforce using REST API
✓ Create Record in Salesforce using REST API
✓ Update Record in Salesforce using REST API
✓ Delete Record in Salesforce using REST API
✓ Other REST API Calls
✓ Extra Bytes
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 80
Celebrate Your Learning
■ Though the examples in this guide is specific to Salesforce, you
can use Advanced REST Client (ARC) extension to test REST API
Calls with any other technology like Google, Facebook, Twitter etc.
■ Have the Vodka to celebrate your learning. You have dipped your
feet into one of the most powerful features of a platform (or any
platform for that matter) - How to integrate it with other applications
using APIs
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 81
Leave Your Feedback
To download the PDF copy of the presentation please navigate to URL
http://www.asagarwal.com/a-60-minutes-step-by-step-diy-guide-to-sales
force-rest-api-for-non-developers. And also please do not forget to
leave your comments/feedback/suggestions at this URL
If you got stuck anywhere and were able to resolve the issue, mention
that as a comment on the above mentioned blog post URL so that
others can benefit from your experience
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 82
Thank You !
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 83
Document Change Log
Version Changes
1.0 First Release
Visit asagarwal.com for daily dose of useful tips and tricks on Salesforce 84