Since the introduction of SAP S/4HANA Cloud, API Business Hub acted as the central catalog where our partners and developers can explore the S/4HANA Cloud APIs. Those APIs enable you to integrate your SAP S/4HANA Cloud solution with other SAP products (Cloud or On-premise) and 3rd party products.
We’ve just introduced a S/4HANA Cloud public sandbox system to ease the use of APIs by our partners and developers for testing purposes. The sandbox system can be used for testing APIs with a read-only access. In order to test write operations, the tests should be performed against your SAP S/4HANA Cloud system. This Blog will explain how the new sandbox system might be helpful for you.
Exploring and testing API operations with ‘Try-it-out’
You are now able to explore the different operations offered with S/4HANA Cloud OData services and see how would the responses look like. This would help you in identifying if an API is suitable for your integration needs or not.
You need to be logged in to SAP API Business Hub in order to use the ‘Try-it-out’ feature. All the possible OData operations which you can test are available in the resources tab of the service. Taking as an example the OData service ‘Read Sales Contract’. If you go to the resources tab you can see the possible operations for each collection. For the ‘Sales Contract Item’ collection, this is visible below in screenshot 1.
screenshot 1: Entitysets and opertions for the ‘Read Sales Contract’ API
By expanding one of the operations, you can see more details about it. You can then click on the ‘Try-it-out’ button. API Hub then triggers a request to the sandbox system and the response received is displayed on the API Hub UI. In case you need to add any parameters to the request, this is also possible via the UI.
screenshot 2: Response code and body after triggering the request via the ‘Try it out!’ button
If you need to use the SAP API Business Hub to test SAP S/4HANA Cloud APIs against your own system, there is a new feature which enables you to create and configure an ‘API Endpoint’. You can use this feature to test write operations for an API. For more information on configuring API endpoints please refer to this guide.
screenshot 3: Configuring you own API endpoint
Building Fiori applications on ‘SAP Web IDE’
You can build applications that consume services exposed on the S/4HANA Cloud sandbox system making use of the SAP API Business Hub integration with the SAP Web IDE Full-Stack version. This feature can be used to demonstrate how SAP Cloud Platform can be used to enhance and extend your SAP S/4HANA Cloud solution.
To consume the APIs in SAP Web IDE, you need to select ‘New Project from Template’ and in the data connection section of the wizard you can select the source as ‘SAP API Business Hub’, then select the ‘SAP S/4HANA Cloud’ package from the drop down menu to filter the services. You can also get more details and further documentation about the API in the ‘API Details’ section.
screenshot 4: Consuming S/4HANA Cloud APIs on SAP Web IDE Full-Stack version
Testing APIs from REST clients and custom applications
You can also make use of the APIs exposed on the sandbox system in any of your preferred REST clients or custom applications (not build on SAP Web IDE). In order to be able to consume the sandbox APIs, you need to add an ‘apikey’ attribute in the request header. The API Key can be obtained from the SAP API Business Hub as shown below (You need to be logged in).
screenshot 5: API Key for the SAP S/4HANA Cloud sandbox
You can also use the ‘Generate Code’ feature which provides you prepared code snippets in different programming languages which you can directly copy-paste into your application.
screenshot 6: Generating code snippets for custom API usage.
- The SAP S/4HANA Cloud sandbox system for API Business Hub can only be used for testing purposes and not for productive application development or use cases.
- The SAP S/4HANA Cloud sandbox system allows only read operations. Write operations are not allowed against the sandbox system.
- The SAP API Business Hub integration with SAP Web IDE is only available for the ‘SAP Web IDE Full-Stack’ version.