Salesforce APIs全面解析笔记详情 - 应用场景&图解实例

构成:Salesforce APIs include REST API, SOAP API, Bulk API, and Streaming API. Together they make up the Salesforce data APIs. 

目的:Their purpose is to let you manipulate your Salesforce data


1REST API its an excellent choice of technology for use with mobile applications and web projects.

简介:REST API is a simple and powerful web service based on RESTful principles. 

资源类别:It exposes all sorts of Salesforce functionality via REST resources and HTTP methods. 

数据操作:For example, you can create, read, update, and delete(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.

Rest请求四大构成要素:A REST request consists of four components: a resource URI, an HTTP method, request headers, and a request body. 

工具:Workbenchcheck out cURL or Postman

URI(/services/data/v36.0):For convenience, the top-level domain is omitted from the displayed URI. For example, the full URI of the resource thats prepopulated in the URI text box is https://foo.my.salesforce.com/services/data/v36.0.

注意:

在解析某一对象元数据时,所有小写,如:/services/data/v39.0/sobjects/account/describe

在使用Post HTTP Methond插入数据时注意,字符串必须使用双引号,如下:Phone类型数据也写成双引号

最佳实践:

1、插入记录

背景(/services/data/v39.0/sobjects/account     Post        Workbench

{

    "Name": "A-Post Test Account",

    "Type": "Prospect",

    "Phone": "(023) 444-1837"

}

https://componentstest-dev-ed.my.salesforce.com/services/data.json查看版本系列/.xml

Salesforce APIs全面解析笔记详情 - 应用场景&图解实例_第1张图片

2、查找记录

/services/data/v39.0/sobjects/account/0012800001VHuls.xml (xml格式)

/services/data/v39.0/sobjects/contact/00328000015jLeS/account (查询父记录)

背景(Get        Workbench

/services/data/v39.0/query/?q=SELECT+Name+FROM+Account+WHERE+Phone='(023)+444-1837'

Salesforce APIs全面解析笔记详情 - 应用场景&图解实例_第2张图片

Use Apex REST API when you want to expose your Apex classes and methods so that external applications can access your code through REST architecture. 

Apex REST API supports both OAuth 2.0 and Session ID for authorization.


Rest Resourcea single data record, a collection of records, or even dynamic real-time information.  URI

standard HTTP methods{HEAD, GET, POST, PATCH, DELETE} no PUT, PUT was used to replace the entire resource, not used in Force.com REST API.

CRUD


Method & Function

====================================================

HTTP method CRUD

———————————————

HEAD R(Retrieve information but lacks resp and body)

GET R(Retrieve information)

POST C(create a new object)

PATCH U(update a record)

DELETE D(delete a record)


Exposing REST Service - Endpoint:

===================================

1.For Security End Points: Use a connected App

2.For Open End Points: Use Salesforce Sites


Calling REST Service:



2SOAP APIFor example, you can use SOAP API to integrate Salesforce with your orgs ERP and finance systems. 

简介:SOAP API is a powerful web service. It uses a Web Services Description Language(WSDL) file to rigorously define the parameters for accessing data through the API. 

支持格式:SOAP API supports XML only. 

备选方案:Most of the SOAP API functionality is also available through REST API. It just depends on which standard better meets your needs.

应用优势:Because SOAP API uses the WSDL file as a formal contract between the API and consumer, its great for writing server-to-server integrations.

WSDLs及分类:Web Services Description Language, It contains the bindings, protocols, and objects to make API calls. | Enterprise(strongly typed | integration for a single Salesforce org) and Partner(loosely typed | For several orgs) WSDLs

/c—Specifies that were using the enterprise WSDL. Use /u for the partner WSDL.


ToolsWere using a third-party tool called SoapUI to consume our enterprise WSDL file. SoapUI is a free and open-source app for testing web services.

登录时password需要password+security_token e.g. 

         username

         password+security_token

 


登录时会遇到如下问题:

TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using httpshttps://salesforce.stackexchange.com/questions/142362/tls-1-0-has-been-disabled-in-this-organization-please-use-tls-1-1-or-higher-whe

Critical Updates
重要更新


help documentionhttps://help.salesforce.com/articleView?id=000221207&type=1


TLS 的全称是“安全传输层协议”。这是在两个通信应用程序之间提供隐私和数据完整性的协议,并且可用于 Web浏览器和其他需要通过网络安全交换数据的应用程序。

Salesforce 要求在 2017 7 22 日前升级到 TLS 1.1 或更高版本。我们将在该日期开始禁用 TLS 1.0 加密协议,这将阻止仍使用该协议的客户访问一些 Salesforce服务。




Use Apex SOAP API when you want to expose Apex methods as SOAP web service APIs so that external applications can access your code through SOAP.

Apex SOAP API supports both OAuth 2.0 and Session ID for authorization.


3Bulk API

主要用途:Bulk API is a specialized RESTful API for loading and querying lots of data at once. By lots, we mean 50,000 records or more. 

特征:Bulk API is asynchronous, meaning that you can submit a request and come back later for the results. 

用例:Bulk API is great for performing tasks that involve lots of records, such as loading data into your org for the first time.


4Streaming API

简介:Streaming API is a specialized API for setting up notifications that trigger when changes are made to your data. 

模型:It uses a publish-subscribe, or pub/sub, model in which users can subscribe to channels that broadcast certain types of data changes.

优势:The pub/sub model reduces the number of API requests by eliminating the need for polling. Streaming API is great for writing apps that would otherwise need to frequently poll for changes.


5Metadata API

功能:Use Metadata API to retrieve, deploy, create, update, or delete customizations for your org. 

用例:The most common use is to migrate changes from a sandbox or testing org to your production environment. 

区别:Metadata API is intended for managing customizations and for building tools that can manage the metadata model, not the data itself.


6Tooling API

Use Tooling API to manage and deploy working copies of Apex classes and triggers and Visualforce pages and components. You can also set checkpoints or heap dump markers, execute anonymous Apex, and access logging and code coverage information.


你可能感兴趣的:(Sales,Cloud,Salesforce,Experience)