a 60 minutes step by step diy guide to salesforce rest api for non developers

84
Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce Step-By-Step DIY Guide To Salesforce REST API For Non- Developers 1

Upload: ashish-agarwal

Post on 08-Jan-2017

6.751 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Step-By-Step DIY GuideTo Salesforce REST API For Non-

Developers

1

Page 2: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Using This Guide

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

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 advised. You may not be able to complete the guide successfully if you miss these instructions

General explanation/information to support actions mentioned on the slide. Will assist you in understanding what is being done and why

Actions that you need to follow to configure. Carry out these steps in the order of their serial number.

Appears on the bottom bar of the page on right hand side. Provides information on the Hardware and Software currently being used

Text with Red Background

Text with Yellow Background

1. Text with White background, red border and a number. In a callout format

Text with Green Background

2

Page 3: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

■ 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

3

Page 4: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

A 60 Minutes Step-By-Step DIY Guide to Salesforce REST API for Non-Developers

http://www.asagarwal.com/4334/a-60-minutes-step-by-step-diy-guide-to-salesforce-rest-api-for-non-developers

Please do not forget to refer to the above blog post for related information, useful links and videos

Related Blog

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 4

Page 5: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

■ 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. :-)

Ingredients

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 5

Page 6: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

➡ 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

6

Page 7: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Login To Salesforce

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 7

1. Login to Salesforce Org

Chrome on Mac

Page 8: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Get Your Security Token

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 8

1. Click on your name -> My Settings

If you do not already have your security token, follow these steps to

get your security token. If you already have the security token, you

can skip this section

Chrome on Mac

Page 9: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Get Your Security Token

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 9

1. Click on Personal

2. Click ‘Reset My Security Token’. If you have specified the ‘Login IP Ranges’ at the profile level, then you will not see option. In that case you don’t need the

security token and you can skip the rest of the steps in this section

Chrome on Mac

Page 10: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Get Your Security Token

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 10

1. Click ‘Reset Security Token’. The security token will be emailed

to your email address

Chrome on Mac

Page 11: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Get Your Security Token

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 11

1. You will get the confirmation that the security token has been emailed to your email address

Chrome on Mac

Page 12: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Get Your Security Token

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 12

1. Navigate to your inbox and copy and paste the security token

in a text editor

Chrome on Mac

Page 13: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 13

1. Back in Salesforce, Click on Setup

Chrome on Mac

Page 14: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 14

1. Navigate to Create -> Apps2. Click New

Chrome on Mac

Page 15: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 15

1. Specify the Connected App Name, API Name and Contact

Email

Chrome on Mac

Page 16: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 16

1. Check Enable OAuth Settings

2. Specify Callback URL. Just specify the value https://localhost:8080. This will not

be used

3. Select ‘Full Access (full) from Available OAuth Scopes and move it to Selected

OAuth Scopes

4. Click Save

Chrome on Mac

Page 17: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 17

1. Click Continue

Chrome on Mac

Page 18: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 18

1. Copy and paste the Consumer Key in a text editor. We will need to

use it later

2. Click on ‘Click to reveal’ for Consumer Secret

Chrome on Mac

Page 19: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Create Connected Apps

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 19

1. Copy and paste the Consumer Secret in a text editor. We will need

to use it later together with Consumer Key

2. Click on Manage

Chrome on Mac

Page 20: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 20

1. Click Edit

Chrome on Mac

Page 21: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 21

1. Under OAuth Policies for ‘Permitted Users’ select the value ‘Admin approved users are pre-

authorized’

Chrome on Mac

Page 22: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 22

1. Click OK

Chrome on Mac

Page 23: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 23

1. Click Save

Chrome on Mac

Page 24: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 24

1. Scroll down the page

Chrome on Mac

Page 25: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 25

1. Click on Manage Profile

Chrome on Mac

Page 26: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Grant Permission to User’s Profile

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 26

1. Select the Profile of the user who will be connecting through

REST API 2. Click Save

Chrome on Mac

Page 27: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Verify that the User’s Profile is API Enabled

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 27

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

Page 28: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

28

Page 29: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 29

1. Open Google Chrome and click on ‘Customize and control Google

Chrome’ icon

2. Select More Tools -> Extensions

Now let’s proceed to install the Advanced REST Client in Google

Chrome Browser

Chrome on Mac

Page 30: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 30

1. Scroll down the page and click ‘Get more extensions’

Chrome on Mac

Page 31: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 31

1. Type ‘Advanced REST Client’ and press Enter

Chrome on Mac

Page 32: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 32

1. Click ‘Add to Chrome’ for Advanced REST Client

Chrome on Mac

Page 33: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 33

1. Click Add App

Chrome on Mac

Page 34: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 34

2. Click on ‘Advanced REST client’

1. Click on ‘Apps’ icon in Google Chrome to view all Apps

installed in Google Chrome

Chrome on Mac

Page 35: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Install Advanced REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 35

Now we are ready to explore the magic of Salesforce REST API. The first thing we

need to do is to connect to Salesforce from Advanced REST Client

ARC in Chrome on Mac

Page 36: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

36

Page 37: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Connecting to Salesforce from REST ClientTo 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=password&client_id=<client_id>&client_secret=<client_secret>&username=<username>&password=<password><security_token>

Replace the value highlighted in blue with your own values

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 steps3. Replace <client_secret> with Consumer Secret copied in previous steps4. Replace <username> with your Salesforce Username5. Replace <password> with your Salesforce password. Append the security token

if required

37

Page 38: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Connecting to Salesforce from REST ClientSo your final connection string should like something like this

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=3BRG9rKhT8ocoxGlaFYGe98k75x5bSs1_f2tFh.EM7PpvDCu.d_wubQWT0yPLUlit0599q.1Bz8Ud_2Ujkf9Z&client_secret=472345243512440999&[email protected]&password=ilovesalesforceiAb1J1diHc8DSVle9dTZJ4Q0e

No, Don’t try to connect using the above string. These are not the actual values of my Salesforce Org. :-)

38

Page 39: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Connecting to Salesforce from REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 39

1. In Advanced REST Client, paste the connection string here2. Select the method as

POST

3. Click ‘Send’ and keep your fingers crossed

ARC in Chrome on Mac

Page 40: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Connecting to Salesforce from REST Client

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 40

1. Scroll down the page and look the value in the status column. If the status is 200, bingo. You have successfully

logged on to Salesforce

2. Look at the values returned by Salesforce. Copy and paste these values in a text editor. We will

need to use some of these values in subsequent calls

If you don’t get the status 200 or see “authentication failure”, you will need to review the steps that you have completed so far and

ensure that all the instructions were followed correctly. Also make sure

that your password does not contain ‘&’ (ampersand) character

ARC in Chrome on Mac

Page 41: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

41

Page 42: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Execute Query through REST APINow 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>

Replace the value highlighted in blue with your own values

1. Use the value of instance_url returned in the response of the login call2. 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

42

Page 43: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Execute Query through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 43

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

3. Set the Header of the REST API Call to Authorization: Bearer <access_token>

where the value of the access token is the value returned in the response of the login call

2. Select the HTTP method to

GET4. Click Send

ARC in Chrome on Mac

Page 44: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Execute Query through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 44

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

Page 45: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Execute Query through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 45

1. If everything goes well, you should see a status of 200 returned by the API. This means that your request

was successful

2. And here is the response to your query in JSON format. We

can also get the response in XML format but hold on to that for now. We have other more

important things to learn

ARC in Chrome on Mac

Page 46: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Review StepsNow 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

46

Page 47: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

47

Page 48: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Creating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 48

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>

Here I am creating an ‘Account’ Record

3. Set the Header of the REST API Call to Authorization Bearer <access_token>

Content-Type application/json

2. Select the HTTP method to

POST

5. Click Send4. 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 and enter the values as shown here. The value is entered in format of

“Field API Name”: “Field Value”

ARC in Chrome on Mac

Page 49: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Creating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 49

1. And Voila, Salesforce REST API has dutifully created the record in

Account object in Salesforce

2. In the response to the Create Call, Salesforce sends you the Salesforce Record Id, a success flag and errors. If you see any errors here, correct the

error and retry

ARC in Chrome on Mac

Page 50: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Creating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 50

1. If you don’t believe me, logon to your Salesforce instance, navigate to Account tab see it for yourself. The Account you just created using Salesforce API

very much exists there

Chrome on Mac

Page 51: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

51

Page 52: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Updating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 52

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>

3. Set the Header of the REST API Call to Authorization Bearer <access_token>

Content-Type application/json

2. Select the HTTP

method to PATCH

5. Click Send4. To update the record, follow the same method as Create. Specify the fields and their values 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

“Field API Name”: “Field Value”

ARC in Chrome on Mac

Page 53: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Updating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 53

1. And the status code that you will receive this time is 204.

2. However, there is no content in the response. This does not mean that the record has not been updated. This just

means that Salesforce has no response to send if it updates the record successfully.

ARC in Chrome on Mac

Page 54: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Updating Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 54

1. You are still not believing me. Come on. Refresh your Account tab in Salesforce and see it for

yourself.

Chrome on Mac

Page 55: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

55

Page 56: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Deleting Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 56

1. Ok, let’s complete the cycle. Now, we will delete the record we just created. To delete 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>

3. Set the Header of the REST API Call to Authorization Bearer <access_token>The Content-Type is not required here

2. Select the HTTP

method to DELETE

4. The Payload is also not required so just click on Send

ARC in Chrome on Mac

Page 57: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Deleting Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 57

1. The status code that you will receive is again 204.

2. And there is no content in the response (unless there are any errors). Salesforce has deleted the record

successfully

ARC in Chrome on Mac

Page 58: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Deleting Record through REST API

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 58

1. Switch back to Salesforce and go to Recycle Bin and the record you just deleted has been moved to

Recycle Bin

Chrome on Mac

Page 59: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

59

Page 60: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 60

1. To get a list of all the objects in your Salesforce instance use the URI

https://<instance_url>/services/data/v35.0/sobjects/

3. Set the Header of the REST API Call to Authorization Bearer <access_token>

Now that we have learnt how to query, create, update & delete

using REST API, let’s explore some more API calls

4. Click Send

2. Set the HTTP

Method to GET

ARC in Chrome on Mac

Page 61: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 61

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

Page 62: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 62

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

3. Set the Header of the REST API Call to Authorization Bearer <access_token>

4. Click Send

2. Set the HTTP

Method to GET

ARC in Chrome on Mac

Page 63: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 63

1. And in response you will get a list of all the child relationships, fields and its attributes on the specified

SObject

ARC in Chrome on Mac

Page 64: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 64

1. To get a list of all the field values on a particular record use the URIhttps://<instance_url>/services/data/v35.0/sobjects/<Object Name>/<Salesforce Record Id>

3. Set the Header of the REST API Call to Authorization Bearer <access_token>

4. Click Send

2. Set the HTTP

Method to GET

ARC in Chrome on Mac

Page 65: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Other REST API Calls

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 65

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

Page 66: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

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

66ARC in Chrome on Mac

Page 67: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

67

Page 68: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Extra BytesHopefully 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

68

Page 69: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Getting Response in XML Format

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 69

To get the response in XML format, all you need to do is to set the Request Header to Accept application/xml

By default all responses to REST API Calls are in JSON format.

However you do have the option of getting the response in XML format

also

ARC in Chrome on Mac

Page 70: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Getting Response in XML Format

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 70

Salesforce REST API will now return the response in XML

format

ARC in Chrome on Mac

Page 71: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Sending Payload in XML Format

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 71

2. And make sure that the Payload is in XML format as shown here. The field API Names are appearing as XML

tags in the Payload

Any Payload that you are sending to Salesforce should be in JSON

format. However you also have the option of sending the payload in

XML format

1. To send the payload in XML format, you need to specify the request header to

Content-Type application/xml

ARC in Chrome on Mac

Page 72: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Sending Payload in XML Format

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 72

1. Salesforce creates the record and returns the response in XML format because in the REST Call on previous slide, we also set the request header to

Accept application/xml

ARC in Chrome on Mac

Page 73: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Useful Information - Supported HTTP MethodsSalesforce REST API supports the following HTTP Methods

■ HEAD (to retrieve resource metadata)■ GET (to retrieve information)■ POST (to create a record)■ PATCH (to update a record)■ DELETE (to delete a record)

73

Page 74: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

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_rest/errorcodes.htm

74

Page 75: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

ARC Features - Save

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 75

1. You can save your REST API Call details for future use. In ARC click on ‘Save’

ARC in Chrome on Mac

Page 76: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

ARC Features - Save

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 76

1. Specify a Name and click ‘Save’

ARC in Chrome on Mac

Page 77: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

ARC Features - Open

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 77

1. Once saved, you can reload the API call details by clicking on Open

ARC in Chrome on Mac

Page 78: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

ARC Features - Open

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 78

1. Click on ‘Select’ for the desired call

ARC in Chrome on Mac

Page 79: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

ARC Features - History

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce 79

1. In ARC, click on History to view a history of all the recent calls made to

Salesforce

2. Click Select to reload the API call in

ARC

ARC in Chrome on Mac

Page 80: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Steps Overview

Visit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

✓ 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

80

Page 81: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Celebrate Your Learning

81

■ 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

Page 82: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Leave Your FeedbackAnd before you get drunk, please do not forget to leave your feedback/suggestions on my blog at URL http://www.asagarwal.com/4334/a-60-minutes-step-by-step-diy-guide-to-salesforce-rest-api-for-non-developers

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

82

Page 83: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Thank You !

For Daily Dose of Useful Tips & Tricks on Salesforce.com Please Visithttp://www.asagarwal.com

83

Page 84: A 60 Minutes Step by Step DIY Guide to Salesforce REST API for Non Developers

Visit asagarwal.com for daily dose of useful tips and tricsk on SalesforceVisit asagarwal.com for daily dose of useful tips and tricsk on Salesforce

Document Change LogVersion Changes

1.0 First Release

1.1 Re-ordering of 1st 3 slides to make links it clickable on Slideshare

84