For Salesforce CRM online Training please contact :+91 9964773322 or +91 9393934143. Website : https://www.salesforcestart.com/
Tuesday, 11 April 2017
Friday, 7 April 2017
How to Test Salesforce REST API
How to Test Salesforce REST
API
To Test
Salesforce Rest API First we need to create Connected App in Salesforce.Once we
created Connected App it will generate consumer or client id and consumer
secret.
After that
we need to create Access-token using below steps.
1.grant_type=password&client_id=YourClientId&client_secret=YourClientSecret&username=YourUserName&password=YourPassword+securitytoken
EX:
client_id
=
3MVG9ZL0ppGP5UrB.7GK_luxRT7StxC8dM37EZzuyrj0LMr_TaiMZatpDKASHUikAvgczZCo1ONfmzhV5LER1
client_secret
= 1328342625760846904
username = username
password=YourPassword+securitytoken
Content-Type
: application/x-www-form-urlencoded
Here we will
get response like below format:
{"access_token": "00D28000001xtTR!AQkAQO.ZKKI4ccUpsQLzm.RpgI4HxLuMU8vqrpmpku_DEc3_aHMs9ar60o_l2HR9Vc2cF3IbFS8jC5UDD38h3CmXvBX6ue42","instance_url": "https://ap2.salesforce.com","id": "https://login.salesforce.com/id/00D28000001xtTREAY/00528000005dGo3AAE","token_type": "Bearer","issued_at": "1491551856783","signature": "RxPY7+SXQEyaIzTW3B5c1N/0C3ciwhojKNbULX9Xawo="}
Now we will
test Rest WS using above access token.
Sample
RestClass:
@RestResource(urlmapping
= '/showAccounts/*')
global class
RestExample {
@HttpGet
global static list<account>
getAccounts(){
list<account> lstAccounts = new
list<account>();
RestRequest request =
RestContext.request;
system.debug('request >>>' +
request);
string accName =
request.params.get('name');
system.debug('==accName==='+accName);
lstAccounts = [select id,name,phone
from account where name =: accName];
system.debug('===result==='+lstAccounts);
return lstAccounts;
}
}
Using Below
Extensions also we can test REST WSs.
Advanced REST client -
Chrome Web Store
Postman - Chrome Web
Store
Tuesday, 4 April 2017
Sample Comments for classes and methods.
Class Comments:
/*********************************************************************************
Class Name: SampleClass
Purpose: 1. This is the class for creating data.
Please maintain only the last 5 history changes/modifications in the audit log
History of Changes:
--------------------------------------------------------------------------------------------------------------------------
Date Developer Comments
--------------------------------------------------------------------------------------------------------------------------
07-Feb-2017 Developer Name Added new method
********************************************************************************/
public class SampleClass{
Method Comments:
/*
* MethodName : sampleMethod
* Description : searching all accounts data based on name.
*/
public static void sampleMethod(){
}
}
/*********************************************************************************
Class Name: SampleClass
Purpose: 1. This is the class for creating data.
Please maintain only the last 5 history changes/modifications in the audit log
History of Changes:
--------------------------------------------------------------------------------------------------------------------------
Date Developer Comments
--------------------------------------------------------------------------------------------------------------------------
07-Feb-2017 Developer Name Added new method
********************************************************************************/
public class SampleClass{
Method Comments:
/*
* MethodName : sampleMethod
* Description : searching all accounts data based on name.
*/
public static void sampleMethod(){
}
}
Subscribe to:
Posts (Atom)
Complete Salesforce CPQ training Free videos
Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...
-
Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...
-
Salesforce advanced admin certification dumps More Videos: Salesforce advanced admin certification dumps
-
External ID This is a field that usually references an ID from another (external) system. For instance, if the customer has an Oracle Fi...