SAP IoT Application Enablement (IoT AE) has published in the SAP API Business Hub the services descriptions using the OpenAPI format on which SAP is a member.
This means that the IoT AE API is described in a standard way and this description may be used to jump start testing and development on your project.
We will see further a few tips and tricks on how to use the SAP IoT Application Enablement API description in Postman and with a code generation tool for different programming languages and frameworks.
SAP API Business Hub
The SAP API Business Hub is very useful website for any developer starting with or already working on SAP technologies.
In this website you can search and find APIs exposed by SAP and its partners.
Anyone can speed up discovery and prototypes using the API Sandbox and can try out APIs in minutes before using them productively.
SAP API Business Hub is the central catalog of all SAP and partner APIs for developers to build sample apps, extensions and open integrations with SAP.
How to Download JSON/YAML descriptor
- Open the SAP API Business Hub website link
- Go to Browse to discover APIs (middle left on the first page)
- Search after ‘SAP Internet of Things‘ or ‘Application Enablement‘
- Choose (Click) the result ‘SAP Internet of Things (IoT) Application Enablement services‘
- See the ‘Artifacts‘ page for exposed services list
- Open any of the services described there (Things, Configuration, Thing Analytics, etc)
- The Download Button is located top right and it has 2 options : YAML and JSON
- Download the JSON or the YAML file
How to use it in Postman
- Get Postman from here
- Open Postman
- In the main menu File -> Import
- Select the YAML or the JSON file and click import
- You will find a Postman collection imported with example requests for all exposed HTTP VERBS and endpoints
Tip : If your Postman requests are not working (response code 400 – client error) try to disable the Postman Interceptor (top grey bar, the icon that looks like a satellite, on the left of the Login Button)
How to generate client code in SAP API Business Hub
The fastest way to generate code for this languages (on 27th Sept 2017) is to click the Button Generate Code found on the end of each row that represents an api operation (http verb & url) :
How to generate client code based on the JSON descriptor
The Swagger Codegen may be used to generate client code for all the major programming languages used nowadays (Java, C#, Scala, Go, PHP, Python, Ruby, C++, Node.js, Lua, BASH, etc)
After download, you can see supported programming languages and their codes that may be used to generate code running in terminal :
To run this great tool you need to download the latest Swagger Codegen CLI snapshot from the website
On MacOS you can install with brew install swagger-codegen
To generate code use the command line :
swagger-codegen generate -i PATH_TO_JSON_DESCRIPTOR -l java -o DESTITNATION_FOLDER
* Be sure to edit the bolded variables in the example command line
Describing APIs with the OpenAPI standard gives developers a lot of help and info.
It’s great that SAP provides OpenAPI descriptions for its own APIs and for partner APIs.
It’s even better that all of those descriptions are available and searchable in a complete and unique website called SAP API Business Hub.