Skip to Content

Introduction

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

  1. Open the SAP API Business Hub website link
  2. Go to Browse to discover APIs (middle left on the first page)
  3. Search after ‘SAP Internet of Things‘ or ‘Application Enablement
  4. Choose (Click) the result ‘SAP Internet of Things (IoT) Application Enablement services
  5. See the ‘Artifacts‘ page for exposed services list
  6. Open any of the services described there (Things, Configuration, Thing Analytics, etc)
  7. The Download Button is located top right and it has 2 options : YAML and JSON
  8. Download the JSON or the YAML file

 

How to use it in Postman

  1. Get Postman from here
  2. Open Postman
  3. In the main menu File -> Import
  4. Select the YAML or the JSON file and click import
  5. 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 :

swagger-codegen

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

 

Conclusions

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.

 

Resources and Links

SAP API Business Hub

Open API

Swagger Codegen

Swagger Codegen on GitHub

Swagger Codegen Install Guide

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply