Objective
After completing this lesson, you will be able to manage usage APIs to report, update, and retrieve usage data in SAP Subscription Billing.
Usage APIs to Report, Update, and Retrieve Usage Data in SAP Subscription Billing
Technical Resource IDs play a crucial role in identifying the correct subscription when processing usage data, ensuring that the data is accurately matched with the respective subscription during the billing process.
Upon creating a subscription, the rate element in our example for the BR469 product is designed to automatically generate technical Resource IDs to uniquely identify resources. Alternatively, you have the option to manually maintain your own Technical Resources.
In the following scenario, the system is configured to manage technical resource ID generation automatically. When it comes to uploading usage data to SAP Subscription Billing, each subscription item can be associated with one or multiple technical resource IDs. To begin generating usage data with an API, first acquire the technical resource ID for the subscription item that needs a usage record. You can open the Manage Subscriptions SAP Fiori app in the SAP Subscription Billing system and open the subscription item and check under Technical Resources. You may also send a GET Subscription Request to retrieve all information from the subscription.
Let’s see how to create a new request for a technical resource ID. Watch the following video to get started.
Now that you’ve had a chance to explore creating a technical resource ID with a REST CLIENT, let’s do it ourselves in the next exercise.
Get the Technical Resource ID for Sending Usage Data via API
Steps
Repeat the exercise Get Customer ID and Create a subscription using the POST Subscription API, as the subscription was canceled.
Perform the exercise again.
Create a new Request in Bruno.
Use the following data:
| Field | Value |
|---|
| Name | <of your choice>, for example: Get Subscription |
| Method | Get |
| URL | https://eu10.revenue.cloud.sap/api/usage-record/v1/usage-records |
| Auth | Bearer Token |
Technical resource ID: ______________________________________
Create a new Request in Bruno, by choosing + in the tab.
Give it a name of your choice, for example: Get Subscription.
For the URL, change the method to POST and enter the URL: https://eu10.revenue.cloud.sap/api/subscription/v1/subscriptions.
Choose Create.
Replace the ID in the URL with the Bill ID from the Exercise Send a Get Request to Retrieve Usage Data Information.
Open the Auth tab and select BearerToken.
Enter the Bearer Token from the exercise Generate a Bearer Token to get Authorization for the APIs.
Choose Send.
Check that you receive a "200" Response and see a list with all subscriptions in the system. Once you find your subscription, you can search for the technical resource ID (Under the node "technicalResources"). Take note of the technical resource id.
Once you find your subscription, you can search for the technical resource ID (Under the technicalResources node). Take note of the technical resource id.
Sending Usage Data to the SAP Subscription Billing System
Once you’ve obtained a technical resource ID, your next step is to send usage data to the SAP Subscription Billing system with your API. By providing the technical resource ID, the system associates the usage data with the appropriate subscription.
Within SAP Subscription Billing, the technical resource refers to the specific resources or services that are being consumed by the customer. These could be things like data storage, API calls, network bandwidth, or any other measurable resources or services that are being used within the subscription model. The technical resource is key to accurately tracking and billing customers based on their usage. In our scenario, the technical resource type is called USAGE_FEE and the ID will be an automatically generated technical resource ID. In real scenarios, the type could be, for example, API Calls and the ID could be the IP Address of the device.
In the next video, you will learn how to create a new POST request in Bruno to send usage data to the SAP Subscription Billing System, which you will then apply in the exercise.
Summary
Perform the following two exercises.
Now that you’ve had a chance to upload and consume usage data and create technical resources and their corresponding IDs, in the next unit you will manage Bill APIs to create, retrieve, update, and delete information in SAP Subscription Billing.
Send Usage Data to Your Subscription via API
Steps
Create a new Request in Bruno.
Use the following data:
| Field | Value |
|---|
| Name | Create Usage Data |
| URL method | Post |
| Used URL | https://eu10.revenue.cloud.sap/api/usage-record/v1/usage-records |
| Auth | BearerToken |
Choose the + in the tab.
Enter the name from the table.
For the URL, change the method to POST and enter the URL: https://eu10.revenue.cloud.sap/api/usage-record/v1/usage-records.
Choose Create.
Add the Bearer Token.
Open the Auth tab and select BearerToken.
Enter the Bearer Token from the Exercise Get the Technical Resource ID for Sending Usage Data via API.
Enter the JSON, for example:
12345678
"startedAt": "2024-07-05T05:00:00Z",
"endedAt": "2024-07-06T05:00:00Z",
"category": "MEASURED",
"metricId": "USAGE_FEE",
"quantity": 5,
"userTechnicalId": "your technical resource ID"
}
Open the Body tab and select JSON.
Enter the given code.
Choose the Send button.
You should receive a 201 with the ID of the Usage Records.
Result
Now that you've uploaded usage data into the SAP Subscription Billing System, you need to verify whether the data is reflected in the system. You will send a GET request to verify the display of this usage data.
Send a GET Request to Retrieve Usage Data Information
Steps
Create a new Request in Bruno.
Use the following data:
| Field | Value |
|---|
| Name | Get Usage Data |
| URL method | Get |
| Used URL | https://eu10.revenue.cloud.sap/api/usage-record/v1/usage-records |
| Auth | BearerToken |
Choose the + in the tab.
Enter the name from the table.
For the URL, change the method to Get and enter the URL: https://eu10.revenue.cloud.sap/api/usage-record/v1/usage-records.
Choose Create.
Add the Bearer Token.
Open the Auth tab and select BearerToken.
Enter the Bearer Token from the exercise Generate a Bearer Token to get Authorization for the APIs.
Choose Send.