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):
POST http://10.x.x.x:9093/1/workspaces/default/projects/freezer_monitor/streams/MACHINEDATA
The header needs to include our authorization token. In Postman, go to the Headers tab and click on Bulk Edit. Paste in your authorization token and then copy and add the header prefix shown below
header prefix: authorization:SWS-Token "sws-token"=
So that the full header looks something like this:
authorization:SWS-Token "sws-token"="biVBFyKyPYgObPtmZc7y3ygn7e2hr4OoIQHjKtgQU1Hx75zunA3xDOBEQr08lCkhQFi4L7Ze9GNDb3rpNF1jEQ=="
Here’s how the header will look in Postman:
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.
[
{"ESP_OPS":"i", "MACHINEID":"1A", "EVENT_TIME": "2013-03-10T04:45:36.123", "EVENT_NAME":"DOOR", "EVENT_DESCRIPTION":"door open event", "EVENT_VALUE":"Door open"}
]
Here’s how the body will look in Postman:
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:
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:
[
{ "ESP_OPS":"<opcode>", "<field1>":<value1>, "<field2>":<value2>, … },
{ "ESP_OPS":"<opcode>", "<field1>":<value1>, "<field2>":<value2>, … }
]
The structure of the array format is more compact (and a bit more efficient) but is less forgiving:
[
[ "<opcode>", <value1>, <value2>, <value3>, …],
[ "<opcode>", <value1>, <value2>, <value3>, …]
]
With this method, every field must be sent a value, and the order they are typed must correspond to the schema.