Salesforce Rest Integration Using Postman tool

Step 1 :
----------
Create a connect app in salesforce side-
Setup-->Apps-->Connected Apps-->Click on "New".
Connected App Name = "PostManIntegration"
Contact Email="xxxx@gmail.com"
API (Enable OAuth Settings) :-
Enable OAuth Settings=True
Callback URL=https://www.getpostman.com/oauth2/callback
Selected OAuth Scopes="Move all Available OAuth Scopes from left to right".
Click on save button.

Step 2:
---------
Open Post man tool and set authorization.
Select Type = OAuth 2.0
Click on "Get New Access Token" button and fillout the details below-
Token Name =SFDCStage
Auth URL : https://ap4.salesforce.com/services/oauth2/authorize(note:target org details)
Access Token URL = https://ap4.salesforce.com/services/oauth2/token
Client ID =3MVG9YDQS5WtC11rGKIQRhZePOsBtn5nBh78IQfLbKyCCGflGeqtOOG6eQLxyCO7fWtVWd39LVFV7fMZKS4hW
(note: client id copy&paste from connected app)
Client Secret =6074728589680506029
(note: client Secret , copy&paste from connected app)
Grant Type = Authorization Code
click on "Request Token" button.

Once you click on  "Request Token" button. new popup will be opened and ask salesforce credentials. Provide the same and say allow.


Headers :
----------
Key = Content-Type----->Value=application/json

Step 3 :
--------

Now its time to test our application. Create one apex class in same salesforce organization.
Apex Class Example:


@RestResource(urlMapping='/v1/getContacts/*')
   global with sharing class getContact {
     @Httpget
      global static list<contact> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        Id accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        list<contact> lstcontact =[Select id,lastname,Email,leadsource from contact where Accountid=:accId];        
        return lstcontact ;
      }
   }
Step 4 :
--------
From Postman tool select "Get" method and past the below url

https://ap4.salesforce.com/services/apexrest/v1/getContacts/{Your account object id}.
Click on "Send button" and you could see the below output.












Rest API test through postman salesforce

1) go To Create -> Apps ->  Connected App
2) give name  and contact email
3) Click on Enable oauth setting  and give call back url -  https://www.getpostman.com/oauth2/callback and "Selected OAuth Scopes" and Full access
4) Save


Open post man select ouath2 and generate new access token  :-

provide details as below

Tokenname
For authorization: https://ap1.salesforce.com/services/oauth2/authorize
For token requests: https://ap1.salesforce.com/services/oauth2/token
client key
client  secret
and click save it takes you to salesforce page provide your authentication details and and click accept


In Post Man :- click on "Tokenname" - > "Add token to"  give values as "Header" from dropdown and Click on Use Token you can check one header will be added with
name Authorization


Seelct GET request, paste below url :- Refer :- https://blog.mkorman.uk/using-postman-to-explore-salesforce-restful-web-services/

https://ap1.salesforce.com/services/data/v20.0/sobjects/Lead/00Q9000000zCWwb and click send








TEST DATA AND URL's :-
https://login.salesforce.com/services/data/v37/0/sobjects/Account
https://ap1.salesforce.com/services/data/v37/0/sobjects/Account

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/0019000001oLlBR?fields=AccountNumber,BillingPostalCode
https://ap1.salesforce.com/services/data/v20.0/sobjects/Lead/00Q9000000zCWwb

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account
"Authorization:Bearertoken
"Content-Type:application/json"

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/0019000001pav75AAA --retrieve

Create :-

https://ap1.salesforce.com/services/data/v20.0/sobjects/Account/
{
"name" : "Fazurulla",
"Phone" : "9848012345"
}

https://ap1.salesforce.com/services/data/v20.0/sobjects/Lead/
{
"name" : "Fazurulla G"
"Phone" : "9848012345"
"Company" : "TESTCOMPANY"
"Email" : ""f.ganaganapalli@accenture.com"
}

Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular