The REST and Web Socket interfaces for streaming projects are provided by the Streaming Web Service (SWS) - a service of the smart data streaming cluster. At this point SWS should already be running on your SDS cluster. Let’s make sure we can connect to it.

To do this, send a simple http GET to the server. You will need substitute the IP address of your HANA system in the URL below:

GET http://10.x.x.x:9093/1/version

Here it is in Postman:

If successful, you should get a response that looks something like this:

If you get an error indicating no response, then you aren’t able to connect to the SWS web server. Check the following:

Double check the IP address (or host name) you are using in the http GET request

Confirm that the smart data streaming SWS web server is running

Step 4: Get an authorization token

Before you can publish messages, SWS requires that you request for a token for the specific resource you intend to access. The returned token then needs to be included in the headers of subsequent POSTs. To get an authorization token we need to send a POST request as follows (substituting the IP address - or hostname - of the host where SWS is running):

POST http://10.x.x.x:9093/1/authorization

The header needs to include basic authorization credentials, where the username and password are base64 encoded. So the header will look something like this:

authorization: Basic U0RTX1VTRVI6UGFzc3dvcmQx

But Postman will construct this for you, and do the encoding. Just go to the Authorization tab, enter your credentials, and click “Update Request”

And now go to the Body tab, select raw, and enter the payload. For this test, we need to request a token that will allow us to publish to the MACHINEDATA stream of the freezer_monitoring project running under the default workspace. Copy this and paste it into the body:

Copy the token - you’ll need it in the next step. Don’t copy the full response, just the token and the surrounding quotes.

Note: The token is only valid for a set number of seconds, which is defined in SDS cluster configuration and can be changed from the HANA cockpit or using the command line tools. The default value is only 5 minutes. After this time period, a new token will need to be requested.

Step 5: Post an Event

Now we’re ready to post our event to the MACHINEDATA input stream of the freezer_monitor project running in the default workspace. The URL for this call looks like this (substituting your IP address or hostname):

Since Postman does not offer a “Token” authorization type, we must change the type back to No Auth so our new token doesn’t get over-written back to a BasicAuth. Go to the Authorization tab and select No Auth from the drop-down.

And now go to the Body tab, select raw, and enter the payload below and then press send.

The first part - "ESP_OPS":"i" - tells SDS this is an insert event. Our freezer_monitor project is only designed to process insert events. SDS also supports update, upsert and delete events based on primary keys, but that’s beyond the scope of this tutorial.

In the studio, check the stream viewer to see that your event arrived and was processed.

You can publish additional events if you like, simply editing the body with different values. Note that for all the features of this demo project to work, you’ll want to stick to these values:

MACHINEID should be one of: 1A, 2B, 3C, 4D, 5E, 6F, 7G in order to successfully join to the HANA table containing reference data for each machine

EVENT_NAME should be one of: TEMP, DOOR, or POWER

For power events, EVENT_VALUE should be either Power on or Power off

Also, some notes on the structure of the body:

The JSON message body can be sent in either of 2 formats:

Map format

Array format

Above we used the map format. Note that with the map format, you don’t have to include every field. Fields that are not included will be set to NULL. You can also include multiple events in a single POST like this: