Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

REST API in Salesforce

139 visualizaciones

Publicado el

Bangalore meetup REST API presentation by Vivek and Swayam.

Publicado en: Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

REST API in Salesforce

  1. 1. REST API Vivek Deepak Swayam Arora
  2. 2. Architecture 1. Stateless 2. Code on demand 3. Easy to use
  3. 3. Open End Point Client Server Request Response Example :- 1. Weather APIs of Yahoo, Google etc. 2. Site URL from SFDC
  4. 4. Authorized End Point
  5. 5. More about REST 1. GET, POST, PUT, DELETE 2. The Force.com REST API supports OAuth 2.0 3. Friendly URLs 4. Mobile Apps 5. Force.com site 6. Web to Anything form
  6. 6. SOAP API REST API SOAP is a protocol REST is an architectural style SOAP defines standards to be strictly followed REST does not define too much standards like SOAP SOAP defines its own security. RESTful web services inherits security measures from the underlying transport XML data format only Plain text, HTML, XML, JSON Less Popular More Popular
  7. 7. Compression • Types of Compression o Response Compression o Request Compression • Compression Headers o Accept-Encoding header. o Content-Encoding header.
  8. 8. Hands On
  9. 9. Creating REST Service 1. Write an Apex Class with annotation @RestResource(urlMapping=‘</resourceURL>*') 2. Create one or more methods using below annotaions:- 1. @HttpGet 2. @HttpPost 3. @HttpDelete 4. @HttpPatch 5. @HttpPut
  10. 10. Exposing REST Service 1. For Secured End Points: Use a Connected App 2. For Open End Points: Use Salesforce Sites
  11. 11. Calling REST Service 1. Add Server End Point to ‘Remote Site Settings’. 2. Generate Access Token and Instance URL 1. HttpRequest req = new HttpRequest(); 2. req.setMethod('GET'); 3. req.setEndPoint(endUrl+'/services/oauth2/token'); 4. req.setBody('grant_type=password' + '&client_id=' + consumerKey+ '&client_secret=' + consumerSecret+ '&username=' + EncodingUtil.urlEncode(userName, 'UTF-8') + '&password=' + EncodingUtil.urlEncode(password, 'UTF-8')); 5. Http http = new Http(); 6. HttpResponse res = http.send(req);
  12. 12. Calling REST Service 3. Calling the REST Api using Access Token: 1. HttpRequest req = new HttpRequest(); 2. req.setMethod(‘GET'); 3. req.setHeader('Content-Type', 'application/json'); 4. req.setEndpoint(instanceUrl+'/services/apexrest/SaveCallLog'); 5. req.setHeader('Authorization', 'OAuth '+accestoken); 6. Http http = new Http(); 7. HttpResponse res = http.send(req);
  13. 13. Thank You!

×