Tuesday, 29 July 2014

REST API


REST API (Salesforce to salesforce connnectivity)
==================================================================================

Hi All
I am going to share my knowledge about the REST Api.
But before starting just a short description would like to give:
REST (REpresentational State Transfer) is a simple stateless architecture that generally runs over HTTP.
- REST stands for Representational State Transfer. (It is sometimes spelled "REST".) It relies on a      stateless, client-server, cacheable communications protocol and in virtually all cases, the HTTP protocol is used.
- REST is an architecture style for designing networked applications. The idea is that, rather than        using complex mechanisms such  as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines.
- In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.
- RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries),  and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.              
  - REST is not a "standard". There will never be a W3C recommendataion for REST. And while there are REST programming   frameworks, working with REST is so simple that you can often "roll your own" with standard library features in languages like Perl, Java, or C#.      

Let implement a simple REST examples:
1- Create two developer Org one is Source and other is destination.
2- Create a connected app in destination Org.(Screen -1)
3- Setup the Remote setting in destination Org .(Screen -2 and Screen -3)
4- Create the Remote setting in source Org. (Screen - 4 and Screen - 5)
4- Create a page and controller on source side. (Screen - 6 and screen - 7)
5- Create a controller class for access the data in destination Org. (Screen -8)
6-  Go to visual force page in source side (Screen- 9) and proceed with clicking the Fetch Auth Token button.
               

First Click on Fetch Auth Token button to fetch the token then only we can proceed with other functionality.

https://docs.google.com/document/d/1bRnoQH1BvLmdUkHH83HQXXt49AoTR0eOFtpRxAIPG4o/edit?usp=sharing

 
The code snippet is also attached below. This example is only dedicate to salesforce to  salesforce communication. 

Screen - 1

 Screen -2
 Screen - 3
 Screen - 4
 Screen  - 6
 Screen - 7
 Screen- 8
 Screen -5
Screen -9

Will share more things soon .
Thanks Nishant Sharma for you guidance and support, who initiated me to prepare this.

No comments:

Post a Comment