Episode 8 – Integrating with Salesforce (Part 1)

Apex, Apex Hours for Students

Salesforce is a service first platform and it is often required to integrate Salesforce with external applications and services. In this episode we will learn about performing callouts to external services using Apex. Join us as you embark on this wonderful journey to become a champion Salesforce developer.

Episode 8 will be presented by Jayesh Tejwani on Feb 19, 2020 at 6 PM Indian Standard Time.

Agenda

  • Web Communication Fundamentals
  • Understanding REST Vs SOAP
  • Message Exchange Formats – XML & JSON
  • Performing Callouts to External Services
    • HTTP Request & HTTP Response
  • Q & A

Most importantly don’t break a leg if you are overwhelmed with the pace of the live sessions. All Apex Hours for Student sessions will be recorded and will be available on our YouTube channel.

Please register here and follow our ApexHours website to get more notification.

Here is some keynote from our session

Authentication

  • User Authentication
    • Username / password
    • Password never expires for API user
    • Profiles based restrictions
    • API only user
    • Limits on number of failed attempts
  • Authorization – OAuth
  • Data Security
    • How is access to data regulated?
  • Network Authentication
    • Login hours and IP ranges
    • Org-wide trusted IP Address List
    • Security Token for login via API or client outside white-listed IP range
  • Make sure the profile of the integration user meets the needs.

Authentication

  • Apex ignores security
  • Session Timeouts
  • Transport Security
    • SSL provides secure transport over HTTPs
  • Outbound
    • Two-way SSL
    • Port Restrictions
      • Port 80, 443, 1024-66535
    • Remote Site Settings
      • Sites which can be invoked from Salesforce

API

  • Application Programming Interface
  • Set of functions and procedures allowing the creation of applications that access the features or data of an OS, application, or other service.
  • Set of specifications, such as Hypertext Transfer Protocol (HTTP) request messages, along with a definition of the structure of response messages, usually in an Extensible Markup Language (XML) or JavaScript Object Notation (JSON) format
  • For example, Twitter’s REST API allows developers to access core Twitter data and the Search API provides methods for developers to interact with Twitter Search and trends data.

Basics of JSON

  • JSON Stand for “JavaScript Object Notation”.
  • Recommended for devices with low processing power or slow internet
  • It is language Independent representation of objects
  • Text based, human readable data exchange format
  • Parsers available in many languages
  • JSON can be transmitted over http / https

{

  “FirstName” : “Apex”,

  “LastName” : “Hours”,

}

JSON to Apex

Json To Apex

JSON to Apex Deserialization

String jsonString = ‘{“FirstName” : “Apex”,”LastName” : “Hours”}’;

Student st = (Student) System.JSON.deserialize( jsonString , Student.class);

Basics of XML

  • XML stands for eXtensible Markup Language like HTML
  • XML tags are not predefined. You need to define your customized tags.
  • Well, the structured format is easy to read and write from programs.

<student>

  <firstname>Apex</firstname>

  <lastname>Hours</lastname>

</student>

JSON Vs XML

JSON XML
JavaScript Object Notation has a type like String, number, Object, Boolean Extensible markup language is type less, and should be string
It is a way of representing objects It is a markup language and uses tag structure to represent data items
Retrieving value is easy Retrieving value is difficult
It does not provide any support for namespaces. It supports namespaces.
It is less secured It is more secure than JSON
Guidelines: Key – Enclosed in double Quotes(String) Value – Can be any datatype {} – Object [] – Array , – Separates data element within Object Guidelines: Element – <lastname>hours</lastname> Element Definition: <xs:element name=”lastname” type=”xs:string”/> Attribute – <lastname lang=”EN”>Smith</lastname> Attribute Definition – <xs:attribute name=”lang” type=”xs:string”/>

Which API Do I Use?

API Name Protocol Data Format Communication
REST API REST JSON, XML Synchronous
SOAP API SOAP (WSDL) XML Synchronous
Chatter REST API REST JSON, XML Synchronous (photos are processed asynchronously)
Analytics REST API REST JSON, XML Synchronous
Bulk API REST CSV, JSON, XML Asynchronous
Metadata API SOAP (WSDL) XML Asynchronous
Streaming API Bayeux JSON Asynchronous (stream of data)
Apex REST API REST JSON, XML, Custom Synchronous
Apex SOAP API SOAP (WSDL) XML Synchronous

REST API

  • Representational State Transfer is a style of software architecture for distributed hypermedia systems.
  • REST API has a lightweight request and response framework
  • Simple, easy to use and powerful web service based on RESTful principles.
  • Expose functionality via REST resources and HTTP methods.
  • (CRUD) records, search or query your data, retrieve object metadata, and access information about limits in your org.
  • REST API supports both XML and JSON.
  • Mobile and Web apps
  • Rest resource is referenced using URI, abstraction of information, access using HTTP methods

REST API

HTTP Methods

Method Action Details
HEAD Retrieve resource metadata
GET / @HttpGet Read Reads or retrieves records
POST / @HttpPost Create Creates records
PATCH / @HttpPatch Update Update fields in existing records
PUT / @HttpPut Upsert Update existing or create records
DELETE / @HttpDelete Delete Deletes records


Recording

Basic of Integration in Salesforce

Basic of REST API, HTTP Method, Calling YouTube REST API from Salesforce


Further Learning

Assignment

Complete below assignment to win $1000 Salesforce Voucher. Click here for rule.

Make Call-out to SmartyStreets API

SmartyStreets API is used to verify the address. In this milestone you need to consume https://smartystreets.com/products/apis/us-street-api

Requirement – The business ask is to verify the address of the event. Use the above API to verify the address & update “Location Verified” field on Event.

Must Have – Use of Error Handling and code re-usability

Don’t forget to register for our next session on Part 2. Check this post for all other session detail.


Please note that we have limit of 500 attendees that can join the online sessions. However, recording will be posted on our YouTube channel. Make sure to subscribe our YouTube channel to get notification for video upload.

So, learn at your pace and free will and ace your journey to Salesforce!

3,330 total views, 33 views today

One thought on “Episode 8 – Integrating with Salesforce (Part 1)

  • Thank you so much for all the sessions…I’m learning a lot. I’m the one that has been asking about sql server integration. sql server database is actually running on AWS and I need that sql server to send data to salesforce and either create sf records or update them. Similarly, I need SF to send data to sql server to update records, never create on sql server. sql server database is the master. I currently use an ETL tool but it is very expensive and I want to use custom code to get this done. I’m confused as to what I need to develop on the SF side and what I need to develop on the SQL server side. Please help me understand all the various pieces that I need to create and do. Thank you so much for all your help on this

Leave a Reply