How to call an API
While the design and implementation of APIs is out of the scope of this book, we’ll briefly cover how to call an API, namely the Salesforce REST API. At a high-level, an API is essentially a request to an endpoint (a URL) with an XML or JSON body (known as the request payload). The endpoint will return a response payload, which may be XML or JSON depending on how it is configured.
Let’s cover what calling a REST API looks like, and examine the request and response payloads as we do. For this, we’re going to use an online utility called Workbench, which is a free-to-use web application for interacting with your Salesforce instance. Note that it is not an official Salesforce product, and therefore support is limited.
To begin, open a web browser and navigate to the URL https://workbench.developerforce.com/login.php
Next, click the checkbox to agree to the terms and conditions, and click the Login with Salesforce button: