Call IoT Application Enablement service APIs with Postman

Use a REST client (Postman) to call SAP IoT Application Enablement service APIs.

You will learn

In previous tutorials, you learned about using Thing Modeler to onboard a computer as the IoT thing, send data to the thing, and retrieve data from the thing. Now, you’ll learn to use Postman to access SAP IoT Application Enablement service APIs.

Application Router

Access to SAP IoT Application Enablement is usually routed through an application router as the single entry point for consumers. The application router handles the user authentication against SAP User Account and Authentication Service (UAA). In addition, the service retains the generated JWT token for the duration of the client logon session. You can define multiple application routers per tenant and you can use one of the router to access IoT Application Enablement services.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appcore-conf/Configuration

In the Headers tab, enter x-csrf-token in the Key column and enter fetch in the Value column.

Click the Send button. The result set returns the latest version of all packages that belong to the same tenant and all packages with scope=public from other tenants. The response payload contains the following details for every package:

Field

Description

id

Unique identifier of the package

version

Latest version of the package

scope

Scope of the package (public, private, and tenant)

services

Indicates configuration service or thing service

The value generated for x-csrf-token is displayed in the Headers tab of the Response section.

Note: This token is only valid for the current login session. When the session expires, the token is not valid. You must use this token to create a thing instance using the POST method. See Step 4.

Enter the request URL https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appcore-conf/Configuration('sap.iotaehandson2.computeriotdevice') to retrieve details of the package sap.iotaehandson2.computeriotdevice.

Click the Send button. The response payload contains the following details for every package:

Field

Description

id

Unique identifier of the package

dependencies

List of dependent packages relevant to this configuration package

description

Description of the configuration package for each language with the corresponding ISO language code

version

Latest version of the package

scope

Scope of the package (public, private, and tenant)

services

Indicates thing service or event service

You can create a thing instance for the thing type generic_computer_3 in the next step.

Note: At rare instances, the method displays 200-OK but without a response payload. In such scenario, ensure to redo Step 1.

To create data for a thing, you must identify the property set type that is used to define property sets for a thing type. Firstly, read details of a thing type and then read details of a property set type.

In Postman, choose the GET method.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Configuration/ThingTypes('sap.iotaehandson2.computeriotdevice:generic_computer_3')

To read details of a property set type sap.iotaehandson2.computeriotdevice:resource_sensors defined for the thing type sap.iotaehandson2.computeriotdevice:generic_computer_3, enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Configuration/PropertySetTypes('sap.iotaehandson2.computeriotdevice:resource_sensors_2')

Click the Send button.Property set type details retrieved. You can use the property cpu_usage to create data for a thing.

Object group is a technical object used for assigning object-based authorizations to user groups. When you assign an object group to a thing, you are allowed to carry out the functions based on the capabilities defined for the user group. You must identify what object group to use while creating a thing.

In Postman, choose the GET method.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things

You can choose an object group ID from one of the things listed in the response payload. You must specify this ID in the request payload for creating a thing.

In Postman, choose the POST method.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things

Click the Send button.Digital twin of your computer device as a thing is created. The URL of the thing created is returned in the Location field of the Header in the response payload.For example, the digital twin device00 of your computer device is created with a unique thing ID 6FD61AF611ED4357A20E2FC56B7CFB2E. You can use this unique ID to retrieve details of the thing.

In Postman, choose the GET method.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things('6FD61AF611ED4357A20E2FC56B7CFB2E')Thing details are retrieved and displayed in the response payload.

Using API endpoints is one of the ways to directly ingest data for a thing. Alternatively, using device management too you can ingest data for a thing.

In Postman, choose the PUT method.

Enter the following request URL: https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things('6FD61AF611ED4357A20E2FC56B7CFB2E')/sap.iotaehandson2.computeriotdevice:generic_computer_3/resource_sensors_2

Enter the following request URL:https://sap-iotaehandson2.iot-sap.cfapps.eu10.hana.ondemand.com/appiot-mds/Things('6FD61AF611ED4357A20E2FC56B7CFB2E')/sap.iotaehandson2.computeriotdevice:generic_computer_3/resource_sensors_2?timerange=1DData is requested for a time range=1 day. The other possible values are: