TC2.25 - Creating a MicroService for IOT App by Exploiting RestCall APIs services

×

Warning message

  • You can't delete this newsletter because it has not been sent to all its subscribers.
  • You can't delete this newsletter because it has not been sent to all its subscribers.

Test Case Title

TC2.25 - Creating a MicroService for IOT App by Exploiting RestCall APIs services

Goal

I can:

Register an external service as a Rest Call

Create a microservice starting from a rest call of an external MicroService

build IoT applications using Microservices performing RestCall in simple manner

Prerequisites

Using a PC or Mobile with a web browser.

Simple skill on use IotBlocks on Nodered.

The following functionalities are available only for specific Snap4city users with specific privileges.

Expected successful result

Being able to implement your IoT application quickly and easily

   

 

 Snap4City Overview: Microapplications, External Services and Microservices

Example 1: Create a Microservice from an external Rest Call (Method Get No Authorization)

  1. For this example we use the Rest Call https://servicemap.disit.org/WebAppGrafo/api/v1/feedback/last/, a Smart City API to request the last feedback sent by the users to service map.
  2. The Rest Call needs as parameters the format of the response and the language of the user.
  3. To create the microservice,  make the login on the snap4city portal
  4. Click on the ‘Resource Manager: Process Loader > MicroServices fot IOT Applications’ menu to view all own resources and the related metadata
  5. Click on the Button (‘Add Microservice') button

Fig: Upload button.

  1. A pop up will open: fill the fields and press the ‘Confirm’ button. For example, if you want to create a Microservice:
  2. When the confirm button is clicked the Microservices is created and a Final User can publish it and then import it directly into an IoT App:
  3. For the publication of the microservice it is necessary that the license given is public and this can be done by writing Public in the field of the license.
  4. You can then press the button that says NO in the Published column. A confirmation will be requested and the user will have to press the Confirm button.
  5. Once the user has published the service, he can import it autonomously into his own Iot Application, through the Import External Microservices menu.
  6. Click on the name of your microservice and next to install
  7. After the correct installation message has been shown at the top of the page, you can search for the node in the left side menu to use it.
  8. And in this example we create a simple flow to show the functionalities offers by this microservice. Inserting these configurations:
  9. And create this simple flow:
  10. Pressing on the button of the node labelled as timestamp, in the debug tab it is possible to see the result of the Rest Call:


Example 2: Create a Microservice from a Rest Call (Method Get WITH AUTHORIZATION)

  1. Follow the previous example until the point 5.
  2. A pop up will open: fill the fields and press the ‘Confirm’ button. For example, if you want to create a Microservice:
    1. App Type: Microservice
    2. Description: Retrieve last tweet and retweet related to a channel
    3. Nature: Services
    4. Sub-Nature: Social Media
    5. Micro Service Title: twitter-last-channel
    6. Help: Retrieve last tweet and retweet related to a channel
    7. url: https://www.disit.org/rttv/query/select.php
    8. parameter: TwRtwChannel
    9. Method: GET
    10. Authentication: Yes

  1. When the confirm button is clicked the Microservices is created and a Final User can publish it and then import it directly into an IoT App:
  2. For the publication of the microservice it is necessary that the license given is public and this can be done by writing Public in the field of the license.
  3. You can then press the button that says NO in the Published column. A confirmation will be requested and the user will have to press the Confirm button.
  4. Once the user has published the service, he can import it autonomously into his own Iot Application, through the Import External Microservices menu.
  5. Click on the name of your microservice and next to install
  6. After the correct installation message has been shown at the top of the page, you can search for the node in the left side menu to use it.
  7. Differently to the previous node in this case in the configuration tab must be inserted also the username and the password to allow the access to the rest call
  8. Creating a simple flow like the previous:
  9. Pressing on the button of the node labelled as timestamp, in the debug tab it is possible to see the result of the Rest Call:

 

 

 

 

 

 

Comments

Hi,

I would like to know how we can use data returned by Micro service inside the dashboard.  Which node we should we use inside IOT application flow for that. I want to simply dispaly all the data returend by micro service into the snap4city dashboard. can you guys  share a sample node-red flow for the same.

 

Thanks & Regards

 

 

 

 

 

 

roottooladmin1's picture

you have to use  the microseerevices of the group "S4C Dashboard".

Input nodes with PIN on rights are for collecting data from dashboard to the IOT App.

Output nodes with PIN on left are for rendering data from the IOT App to the Dashboard.