0% found this document useful (0 votes)
60 views24 pages

Path To Code: Begin Your Salesforce Coding Adventure

This document provides an overview of integrating Salesforce using REST APIs. It begins with basics of JSON and what APIs are. It then introduces REST APIs and shows how to consume REST APIs using Postman, cURL, and Apex. It discusses JSON guidelines and deserializing JSON into Apex classes. Finally, it references additional learning resources and previews the next session on making SOAP callouts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views24 pages

Path To Code: Begin Your Salesforce Coding Adventure

This document provides an overview of integrating Salesforce using REST APIs. It begins with basics of JSON and what APIs are. It then introduces REST APIs and shows how to consume REST APIs using Postman, cURL, and Apex. It discusses JSON guidelines and deserializing JSON into Apex classes. Finally, it references additional learning resources and previews the next session on making SOAP callouts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Path to Code

Begin Your Salesforce Coding Adventure


Episode 8
Integrate Salesforce using Rest API
Speaker
Salesforce MVP
Sr Technical Architect
23x Certified
@Jitendra Zaa
Congratulations - MOAR badges - Week 8
Agenda
• Basics of JSON
• What is API
• Introduction to REST API
• Using Postman to consume Rest API
• Using cURL to consume Rest API
• Using Apex to consume Rest API
Some House Rules
• Please mute your mic
• Keep adding questions in Zoom Q&A Window
• No question is too small
• Questions will be answered in last 15 mins
Basics of JSON
● JSON Stands for “JavaScript Object Notation”.
● Language Independent representation of objects
● Parsers widely available in many languages
● Alternative to XML
● JSON can be transmitted over http / https
XML vs JSON
<Person> {
<FirstName>Foo</FirstName> “FirstName” : “Foo”,
<LastName>Bar</LastName> “LastName” : “Bar”
</person> }
Advantage of JSON
● XML is Verbose
● More size than of equivalent JSON representation because of
repeated Tags
● JSON Simple to represent
● Recommended for devices with low processing power or slow
internet
● REST is very common and supports JSON widely.
● REST and JSON are the music of the internet.
● Google , Yahoo, D&B web services exposed as REST with
response type JSON
JSON Guidelines
Key – Value enclosed in double quotes (String).
Value - can again anything of datatype.
{} – represents Object
[] – represents Array
, - Separates data element within Object
Supports basically four data type:
1.Boolean
2.Number
3.String
4.Object
JSON to Apex Class - Deserialization
JSON String :
Person d = (Person )System.JSON.deserialize(jsonString, Person.class);
{
“FirstName” : “Foo”,
“LastName” : “Bar”
}
Equivalent Apex Class:
Class Person
{
public String FirstName;
public String LastName;
}
API
Stands for “Application Programming
Interface”

API
API

API

SOAP API - XML


REST API - JSON
Rest API
Representational State Transfer (REST)

Authenticate

Make Request
Process
Response
Request Type
• Get
• Get resources
• Post
• Create resources
• Put
• Update existing resource
• Delete
• Delete resources
Example 1: Find Stock Rates
• Use Free API From - https://www.alphavantage.co/documentation/
• Authentication done using parameter API Key
• Example -
https://www.alphavantage.co/query?function=GLOBAL_QUOTE&sy
mbol=ibm&apikey= M47PP7VKAUI80TSC
Tools Available
• cURL
• Postman
• and many more
Sample Apex Code
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://www.alphavantage.co/query?func
tion=SYMBOL_SEARCH&keywords=BA&apikey=demo');
request.setMethod('GET');
HttpResponse response = http.send(request);
String body= response.getBody() ;
System.debug(body);
Trailhead Modules

Apex Integration Services Lightning Platform API Basics


Reference
• JSON vs XML
• Online JSON Editor
• JSON Serialization vs Deserialization
• Free API to check Stock Status
Q&A
Next Episode 9
Integration 101 - Making SOAP Callout
Thanks

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy