Skip to content

Latest commit

 

History

History
95 lines (56 loc) · 4.68 KB

File metadata and controls

95 lines (56 loc) · 4.68 KB

Using Notifier OpenAPI with Postman

Postman is an API platform for using and testing APIs in a simple way. To test the Notifier OpenAPI via Postman, the Notifier app must run on an Edge device. Within Postman, it is necessary to have a valid authentication token to get access to the Edge device. This can be realized by creating a header key Cookie and pass the token (authToken=<token_string>). Otherwisse the request will fail with state 401 "Unauthorized".

You can copy a valid authentication token from your browser cookies, when logged into the Edge device. Using Chrome, go to settings > more tools > developer tools. Hit the tab 'Network', select an incoming reuest and copy it's 'Cookie' value.

postman_header

Paste the value into a text editor and search for the string 'authToken'. Copy the authToken value and paste it into Postman's header key Cookie.

postman_header

A postman collection, that contains all the following requests, can be downloaded here and imported into Postman. Before starting any request, the collection variables must be set properly. A valid authentication token is then provided automatically by executing the IE Edge Device API request '/device/edge/api/v1/login/direct'. This token is set in each request header, when sending a request.

postman_variables

Raise one notification

With this API call you can raise a notification. Therefore a request body is necessary, containing "notificationTypeId", "eventText", "assetId" and "notificationSource". The new notification gets an unique notificationId for identification.

  • notificationTypeId: 1 (alert) / 2 (warning) / 3 (information)
  • eventText: message text (can be any string)
  • assetId: id of asset in Data Service (this is later set as 'Location' of the notification)
  • notificationSource: who sended the notification (can be any string)

AssetId: To get the assetId, look up in Data Service > select asset > copy id from URL.

get_assetid_1

The GET request could look like this:

https://192.168.112.180/notifier/notificationservice/notifications/ext/raise

The body within the Postman request can be defined as JSON format:

{
  "notificationTypeId": "1",
  "eventText": "ALERT from Postman",
  "assetId": "549c3daa33cd4628b02c2e2745f54d80",
  "notificationSource": "Postman"
}

postman_raise

List all notifications

With this API call you get a list of all active notifications from one source. Therefore the parameter "notificationSource" is necessary.

The GET request could look like this:

https://192.168.112.180/notifier/notificationservice/notifications/ext/active?notificationSource=Postman

postman_get_all

List one notification

With this API call you get one active notification from a specific source. Therefore the parameters "notificationId" and "notificationSource" are necessary.

The GET request could look like this:

https://192.168.112.180/notifier/notificationservice/notifications/ext/active/:id?notificationSource=Postman

postman_get_one

Accept one notification

With this API call you can accept an active notification from a specific source. Therefore the parameters "notificationId", "userId" and "notificationSource" are necessary.

The GET request could look like this:

https://192.168.112.180/notifier/notificationservice/notifications/:id/ext/accept?userId=user@siemens.com&notificationSource=Postman

postman_accept

It is important to set the parameters according to the currently active notifications. For example if "notificationSource" is set to 'PostmanX', but this special notification has 'Postman' as source, the request will fail with state 400 "Bad Request".

Clear one notification

With this API call you can clear an active notification. Therefore the parameter "notificationId" is necessary.

The GET request could look like this:

https://192.168.112.180/notifier/notificationservice/notifications/:id/ext/clear

postman_clear