Relevant Fields and Values
Identifying the relevant fields for a specific use case and understanding the values they need to achieve the desired outcome can be challenging. A good approach is to start by creating a sample appointment in the front end. Fill in the relevant fields and then retrieve that appointment via the API. This will provide an overview of the data model, as well as the representation of different values and data types.
There are several ways to examine the data delivered by the API. This lesson discusses three of these methods in detail:
- Browse Real Data in the Integration section of SAP Build Apps.
- Try Out feature of the SAP Business Accelerator Hub.
- Direct access to the REST APIs with your browser or other tools.
1. Browse Real Data
This method allows you to browse the real data of the connected system and inspect single records in more detail. It also offers the capability to create new records or modify existing ones as the following screen capture illustrates. This is the easiest way to browse data of a connected system. However, it requires an existing project with the data integration already enabled. The next approach is more generic and doesn’t have this prerequisite.
2. SAP Business Accelerator Hub
The SAP Business Accelerator Hub is an important source for integration and API related information. You can find it via https://api.sap.com. It provides an overview of the APIs that solutions offer, accompanied by the supported capabilities, operations, and required data structures. It is closer to the technical layer in comparison to the Browse Real Data feature of SAP Build Apps. Instead of simply listing data and creating records with a button, you need to select the API’s capabilities like GET or POST, and can apply parameters on the technical API layer.
The Try Out feature allows you to conduct test calls to either a sandbox environment or real systems after entering the necessary system information. One key advantage of this approach is that you do not need an existing project in SAP Build Apps or a connected system to gain a general overview. The following screen capture demonstrates how to use the Try Out feature to search for an appointment using the non-technical display ID in the previously connected training system.
Carry out the following steps to use the feature:
- Add or select your SAP Sales and Service Cloud Version 2 system as an environment including authentication details.
- Select an operation that you would like to call. In the sample screen capture, it’s GET, which is used to retrieve data.
- Use the Parameters to limit the results. For instance, you can use $top and enter a number to retrieve only this number of records from the system. In the screen capture, $filter is used to filter the result set based on the field displayId and the value 391.
- Finally, run the operation.
The filter condition follows the pattern fieldname eq value (field name, space, comparison operator, space, value) where the field name must be the exact name of the attribute, eq is the comparison operator and stands for equals ( = ). Text values must be quoted with single apostrophes ( ' ).
With the Try Out feature, you can also query the other capabilities of the appointment service, for instance, Appointment Category. The GET operation of the Appointment Category capability returns a list of code-description pairs that reflect the categories set up in the connected system as shown in the following screen capture.
An appointment’s category can be set and read via the category field and the corresponding code. When reading appointment data from the system, there is an additional field categoryDescription, which contains the text for the category code. The created appointment record above contains the category code 1001, which stands for Meeting.
3. Direct Access to the REST APIs
The third option is the most technical one, but it doesn’t need any additional tool besides access to a SAP Sales and Service Cloud Version 2 tenant. This approach allows you to retrieve data via the GET operation from REST APIs simply with the web browser by typing the correct endpoint into the browser’s address bar. Make sure you are logged in to SAP Sales and Service Cloud Version 2 in the same browser window before opening an API endpoint.
The SAP Business Accelerator Hub helps you find the right API endpoint. Instead of using the GET Appointment Categories capability within the Hub's user interface, you can enter the full endpoint directly into your browser's address bar, as shown in the screen capture below.
The full endpoint for the Appointment Categories would look like this:
https://myXXXXXXXXX.crm.cloud.sap/sap/c4c/api/v1/appointment-service/categories
The following listing shows other sample endpoints that you could use to fetch appointments, for instance by their subject, by their displayId, or just the first 10 records from the system:
The first two URLs target the appointment collection of the appointment-service and apply a filter.
The browser will usually escape characters and change the last part of the URL to something like this:
$filter=subject%20eq%20%27Company%20Onboarding%27
Some characters have a special meaning and are not allowed to appear in URLs. In this case, the browser applies the so-called URL encoding, where affected characters are replaced by a % followed by two hexadecimal digits that represent the ASCII value of the character. The %20 stands for a space, and the %27 for a single apostrophe.