Rest API Configuration

From Mikrodev Documentation
Jump to navigation Jump to search

Download Example Project Files

Defining REST API servers

The first thing to do is to define some parameters related with the REST API Server. On the RestTablePanel, click on Add Server button to open New Rest Server Dialog. On the dialog you will be asked the following parameters:

Server URL  
The root url of the server which serves the API
Auth Route Path
If the API requires authentication, set the path for the authentication path here. Do not use the root url here, only the relative path should be inserted(eg : /api/login)
If you need to use any special headers during authentication process insert them in a comma separated key/value format(eg: Key1 : Value1, Key2 : Value2)
Request Body
If you need to use a request body during authentication process insert it here
Expected Auth Token Name
After authentication, if the server sends a token for authentication , insert the name used for token data in here
Token Name For Queries
After you get the token data, you may need to use a different token name on your API calls. Write here the token key name to be used.

Add new REST Request Object

After you add a Rest Server, now you can start to add API request definitions on that server. Click on the Rest Server to which you will add the request and click Add Request button. You need to insert the following parameters on the dialog

The HTTP method to be used for the request. It could be a POST, GET, PUT or DELETE request
Route Path 
The route path of the request. Start with "/" and do not use the root URL here (eg: /api/GetTankLevel)
Request Body 
If you need to use a request body during the API call insert it here
Reply Object Filter 
After you send the API request the server will send you a reply in JSON form. You need to use a filter to be able to get the relevant data from this JSON object. Please see the following example to be able to get the data in different forms:
The example reply from the server is:  
    "Message": null,
    "ResponseModel": {
        "AvailableTags": [
                "CanTakeFuelOutside": false,
                "CurrentMachineHours": 20,
                "THPT": 85,
                "TagNumber": "TestTag000000001",
                "UnitType": "Hour",
                "VehicleTankCapacity": 300
                "CanTakeFuelOutside": false,
                "CurrentMachineHours": 102,
                "THPT": 85,
                "TagNumber": "TestTag000000002",
                "UnitType": "Hour",
                "VehicleTankCapacity": 300
        "ServerDateTime": "14.02.2021 22:01:44"
    "Type": "S"
Example Filters 
  • To be able to get the VehicleTankCapacity of the first element of the AvailableTags array and write it into a block with number 6000 :
ResponseModel.AvailableTags[0].VehicleTankCapacity ,6000;

  • Get all the CurrentMachineHours in the AvailableTags array and write them into a table block with number 6000:
ResponseModel.AvailableTags[].CurrentMachineHours , 6000;

  • Find the object with TagNumber is equal to "TestTag000000002" in the array and get the VehicleTankCapacity value of this object and write that value into the block with block number 6000:
ResponseModel.AvailableTags[].TagNumber(TestTag000000002).VehicleTankCapacity, 6000;
Select Block for Status Value 
The return code of the API request will be written into this block
Select Trigger Block 
Whenever this block is enabled the API request will be sent to server.