Basics: everything to know about Composite API and its advantages

A potential architectural answer that can bundle multiple calls into a single API request.

Salesforce has been helping organizations handle the customer database for over 2 decades. It provides users with the right mix of process automation and personalization and tailor services to the specific requirements of the clients.

Salesforce integration is the process of merging the data and the functionality of salesforce with another application to provide users with a single unified experience. It allows you to provide your team with the ideal platform features.

We have the word ‘Integration’. There are two different systems, and you want to migrate data from one system to another and transfer data to Salesforce. We also have different types of integration like API, Rest API, and Composite API. Let’s discuss Rest API.

Rest API

You can access your Salesforce data through various web interfaces, including REST API, without utilizing the Salesforce user interface. You can carry out activities and incorporate Salesforce into your applications however you’d like with API access.

You can create, modify, and search data in Salesforce using REST API capabilities by submitting HTTP queries to Salesforce endpoints. Resources are distinct information you can access and use depending on where you send requests. Records, search results, information, and other things are all resources.

REST API makes use of RESTful architecture to offer a simple and dependable interface. The fact that REST API only needs a little gear to access your data is one of its main advantages.

Although REST APIs are standard, they may only be effective in some situations. Multiple calls are frequently required to support a single use case when a design is built around particular resources. At the same time, Composite API is a potential architectural solution combining many calls into a single API request.

Composite API

Composite API allows you to carry out several REST API calls simultaneously. The response to one request can serve as input for another. One response body is returned, together with the HTTP statuses of the queries. Regarding your API restrictions, the entire string of requests counts as a single call.

So basically, when any other system wants you to send data to the Salesforce system, you will have to write the Rest apex class (where you will be defining the URL mapping of the class, and using that, the external system can start sending the data to salesforce) which most of us are aware of.

But with Composite API, the external system can send data to the Salesforce system without writing a single piece of code. This is the enhanced feature of Composite API, and Salesforce provides this feature.

1. No external parties involved
2. No managed or unmanaged packages are involved.

Composite APIs offer a greater variety of use cases, making them more potent for users.

Does Composite API support sharing multiple object data?

Suppose you transfer the account data (image below) to Salesforce. But in Salesforce, we have multiple objects like account data, contact, tasks, etc. When we talk about sending the data, the main question is, “Will Composite API support only single object data or multiple object data also?”

The answer is “YES”. Composite API supports all the features to send multiple object data in a single shot.

Before we can send the data to Salesforce, it requires authentication. You can develop and use your connected app to generate the consumer key and consumer secret along with Username, Password & Grant type to complete authentication to send requests properly. Let’s use the postman app, where we enter these five components for authentication, which will generate the access token as shown in the image below.

And once we login into ‘Workbench,’ it is all set for authentication.

With the Authentication complete now, ‘What is the next step? We have to do authorization to start sending the data to Salesforce.

Let us go back to Salesforce, and here we see the 19 records in Salesforce under the account object.

Now, if we want to start sending the data from Salesforce without writing a single piece of code, ‘What will be your next step? & What will be the JSON payload structure?

So let us just add a JSON structure over here, and we’ll know the endpoint URL with which you can directly start sending the data into Salesforce. We’ll use the post method to create or update in Salesforce.

Now on the workbench tool, we’ll post the payload, and as you can see we have the “composite request” under the composite request, we have different sub-breakers. With this feature of composite API, we can use a single API call to do multiple posts and all crowd operations in a single API call. We do not need to write a single piece of code to do three different DML operations, this is the advantage of composite API.

As you can see, we are directly using the endpoint URL here because we are using workbench(now authenticated with salesforce)
We have posted the payload, and as you can see, we have used unique reference IDs for each node. This is because we use a single API call to create the account, contact, and opportunity records. We also link the contact and account records in a single API call.

Now, let us execute this.

Click on “Show Raw Response”

As you can see, everything went perfectly (201 status code).

Now let us go to the Salesforce org and see if the records have been created.

As you can see, there are multiple accounts as we had selected ‘multiple times,’ So let’s choose this Areya account here. And we have the contact record and opportunity record under the account.

Let us open the contact record. As you can see, this contact record is linked to the Areya account.

As you can see, we have the sample contact with the account name linked to it.

Supposing a client requires integration to get data into Salesforce, we just need to ask them a few questions, like what type of data they want to send, like an account object, contact object, or any custom object. We would just need to work on building the payload, and we do not need to write a single piece of code.

The primary purpose here is that it is a declarative way to define the Rest API and Composite API class to the customers without taking much time to write the Apex code. The primary purpose here is that it is a declarative way to define the Rest API and Composite API class to the customers without taking much time to write the Apex code. So we didn’t have to get to the code level. We just have to understand the base requirement of the customers and what attributes they need to send the data to Salesforce.

Takeaway

1. Advantages of composite API.

●  For a single call, many REST API calls.

●  By consolidating the subrequests, processing can be made faster.

●  Enhances the application’s performance.

●  At Salesforce, no additional coding is necessary.

●  One API request per limit.

●  Synchronized reactions.

●  Composite resources can function in several ways.

●  Insert relationships that are five levels deep.

●  Flexible when inserting records that are linked or unrelated.

●  Can do a GET subrequest and then feed the results into a subsequent POST subrequest.

●  Can manage data and objects that are highly complex and linked.

2. Limitations and considerations

●  Some composite resources may not allow for creation and updating.

●  There is an inward API call cap.

●  Troubleshoot

●  Regarding batch and Sobject collections, the reference ID is not returned.

●  The issue with duplicate reference IDs: Same reference id cannot be used in the same transaction.

●  A transaction cannot use the same external id record for the same item twice.

As you know, Composite requests execute a series of REST API requests in a single call. The output of the initial request can be used with the input of a subsequent request. The requests’ response bodies and HTTP statuses are returned in a single response body. As a result, the entire series of requests count as a single call toward your API limits, which is something all developers using the Salesforce ecosystem should be aware of when building integrations and applications.

“Focus your time on delivering features/functionality that extends your intellectual property’s value. Leverage frameworks, products, and services for everything else.”

In this blog, we explored the concept of composite API integration with Salesforce. Indeed, this feature in Salesforce helps feature and service-tier developers to combine related data in a single request, thereby avoiding the additional programming logic required to make the first request and waiting for the response before submitting the subsequent request. We hope this blog helped all to learn something new about composite API.

Let us know your thoughts!

For more blogs: https://areya.tech/blogs/

To know more: connect with us today!
Contact: info@areya.tech

Share:

Facebook
Twitter
Pinterest
LinkedIn
Areya Technologies

Areya Technologies

Trusted Technology Partner

Leave a Reply

Your email address will not be published. Required fields are marked *

Contents

On Key

Related Posts

Tutorial: Basic introduction to LWC

Tutorial: Basic introduction to LWC Lightning Web Components is open source, empowering you to explore the source code, customize the behavior for your needs, and build enterprise-ready web components on any platform, not just Salesforce. Lightning Web Components (LWCs) are a user interface (UI) framework that Salesforce Developers use to create customized pages and functions on the Salesforce platform. Lightning Web Components are seriously becoming the “big thing” for Salesforce Developers, especially for front-end development. Two programming models are now available for creating Lightning components: Lightning Web Components and the original form, Aura Components. Custom HTML elements known as “Lightning

Everything you need to know about SSO (Single Sign-On) and its Importance

Everything you need to know about SSO (Single Sign-On) and its Importance One of the more tedious jobs as a Salesforce admin is resetting users’ passwords. Even though there’s a button on the Salesforce login screen that says “Forgot your password”, some people don’t notice it. If only there were an easier way! Single Sign-On (SSO) is a simple idea: you will instantly be signed into all the other applications you require after signing into one system. You’ll have fewer passwords, fewer headaches, and less redundancy, which should free you up to focus on your original goals rather than getting

Basics: everything to know about Composite API and its advantages

Basics: everything to know about Composite API and its advantages A potential architectural answer that can bundle multiple calls into a single API request. Salesforce has been helping organizations handle the customer database for over 2 decades. It provides users with the right mix of process automation and personalization and tailor services to the specific requirements of the clients. Salesforce integration is the process of merging the data and the functionality of salesforce with another application to provide users with a single unified experience. It allows you to provide your team with the ideal platform features. We have the word

Beginners Guide to MuleSoft and the Anypoint Platform

Beginners Guide to MuleSoft and the Anypoint Platform MuleSoft can connect any system, application, data, and device to unleash the power of Customer 360. The combined power of MuleSoft, the #1 integration platform, and Salesforce, the #1 CRM, enables customers to accelerate digital transformation What is Mulesoft? 1. MuleSoft is a vendor that provides an integration platform to help businesses connect data, applications, and devices across on-premises and cloud computing environments. 2. MuleSoft unifies data to deliver a single view of the customer, automates business processes, and builds connected experiences. Each integration becomes a reusable building block using a modern

San Francisco Headquarters

One Bay Plaza, 1350 Old Bayshore Hwy,#520 Burlingame, CA 94010 ​

Bengaluru Office

IndiQube Edge 4th floor Bellandur, Bengaluru, Karnataka 560103

Pune Office

OYO Workspaces India Pvt. Ltd. Above Vijay Sales, 2nd floor, Pride Purple Accord, Baner road, Baner, Pune - 411045

AREYA