The server is managed and administered through the secured HTTPS protocol, where Monokot Server Administrator acts as the web client, and the server itself operates in the web server mode.
HTTPS enables the use of such function as reading and writing tags, which is, for example, used by the Go Online mode in Monokot Server Administrator. This function can be helpful for use by third-party web clients. For more information on how to access tag values through a third-party web client, see this article.
Please note that access via HTTPS is intended for the internal operation of the server and does not provide the same high data access performance as OPC UA, although it can be used to read and write a small number of tags (up to 200)
We will use Postman as web client. First, let’s allow Postman to accept self-signed SSL certificates. To do this, go to File → Settings and turn off the SSL certificate verification switch in the General category.
Data Reading
Click the + button and select POST request type. In the URL field, enter https://localhost:9881/api/readvalue.
Switch to the Authorization tab, choose Basic Auth in the TYPE drop-down menu, enter admin in the Username field, then enter the administrative password in the Password field (empty line in this example).
Switch to the Body tab, select the raw button and choose JSON as content type.
To read the data, a JSON string should be formed as follows:
{
"$type": "Monokot.Mos.Core.Interaction.MonReadValueRequest, Monokot.Mos.Core",
"Paths": {
"$type": "WPathProt, *",
"$values": [
/* Replace text between BEGIN...END comments with your weak path */
/* ----- BEGIN ----- */
{
"$type": "WPath, *",
"Points": {
"$type": "WPointProt, *",
"$values": [
{
"$type": "WPoint, *",
"Type": 4,
"Id": {
"$type": "TexId, *",
"Text": "TagsManager"
}
},
{
"$type": "WPoint, *",
"Type": 5,
"Id": {
"$type": "TexId, *",
"Text": "Group1"
}
},
{
"$type": "WPoint, *",
"Type": 6,
"Id": {
"$type": "TexId, *",
"Text": "Tag1"
}
}
]
}
}
/* ----- END ----- */
]
}
}
The string is a read request where each read value is specified as a “weak” path to the object that contains it. To get the “weak” path to a tag, in Monokot Server Administrator, open the context menu of the desired tag and click Properties. In the window that appears, copy the value from the Weak Path field.
Replace the text between the comments /*----- BEGIN ----- */ and /*----- END ----- */ with the “weak” path that you copied and paste the request into Postman’s content input field. If you need to read several tags, insert several “weak” paths separated by commas. After that, click the Send button. You will get the following response:
{
"$type": "Monokot.Mos.Core.Interaction.MonReadValueResponse, Monokot.Mos.Core",
"Values": {
"$type": "Monokot.Mos.Core.Interaction.MonReadValueResult[], Monokot.Mos.Core",
"$values": [
{
"$type": "Monokot.Mos.Core.Interaction.MonReadValueResult, Monokot.Mos.Core",
"SourceValue": 0,
"ActualValue": 0,
"Status": 0,
"UtcTime": "2019-09-26T12:46:58.9373633Z"
}
]
}
}
The response is a JSON string where the read tag values are enclosed between the "$values" tokens: [ and ] and. The values are delivered in the order the "weak" paths to the tags were entered. The fields received in the response are:
- SourceValue: current value before conversion
- ActualValue: current value after conversion
- Status: current tag status (0 - Good, 1 - Bad, 2 - BadNoCommunication, 3 - BadTypeMismatch, 4 - BadOutOfRange, 6 - BadNotReadable, 7 - BadLicenseExpired, 8 - BadNotFound, 9 - Uncertain, 10 - UncertainInitialValue, 11 - BadUserAccessDenied, 12 - BadObjectDeleted, 13 - BadNodeIdUnknown, 14 - BadOutOfService)
- UtcTime: time of the last tag update in the UTC format
Please note that in order to perform the reading, it is necessary that the user specified on the Authorization tab (in Postman) has Read Value rights from the Data Access category of the role manager
Current values of time series or expression can be read the same way.
Data Writing
Click the + button and select POST request type. In the URL field, enter https://localhost:9881/api/writevalue.
Switch to the Authorization tab, choose Basic Auth in the TYPE drop-down menu, enter admin in the Username field, then enter the administrative password in the Password field (empty line in this example).
Switch to the Body tab, select the raw button and choose JSON as content type.
To write the data, a JSON string should be formed as follows:
{
"$type": "Monokot.Mos.Core.Interaction.MonWriteValueRequest, Monokot.Mos.Core",
"Paths": {
"$type": "WPathProt, *",
"$values": [
/* Replace text between BEGIN...END comments with your weak path */
/* ----- BEGIN ----- */
{
"$type": "WPath, *",
"Points": {
"$type": "WPointProt, *",
"$values": [
{
"$type": "WPoint, *",
"Type": 4,
"Id": {
"$type": "TexId, *",
"Text": "TagsManager"
}
},
{
"$type": "WPoint, *",
"Type": 5,
"Id": {
"$type": "TexId, *",
"Text": "Group1"
}
},
{
"$type": "WPoint, *",
"Type": 6,
"Id": {
"$type": "TexId, *",
"Text": "Tag1"
}
}
]
}
}
/* ----- END ----- */
]
},
"Values": {
"$type": "System.Object[], mscorlib",
"$values": [
/* Replace text between BEGIN...END comments with your value */
/* ----- BEGIN ----- */
1234
/* ----- END ----- */
]
}
}
Replace the text between the comments /*----- BEGIN ----- */ and /*----- END ----- */ with the “weak” path to the target tag. Replace the text between the second pair of comments /*----- BEGIN ----- */ and /*----- END ----- */ with the value you want to assign. Paste the request into Postman’s input field. If you need to write several tags, insert several “weak” paths separated by commas. After that, click the Send button. You will get the following response:
{
"results": [
{
"status": 0,
"utcTime": "2019-09-28T17:32:23.5001779Z"
}
]
}
The response is a JSON string where the writing results are enclosed between the "results" tokens: [ and ]. The results are received in the order the "weak" paths to the tags were entered. The fields received in the response are:
- status: Operation status (0 - Good, 1 - Bad, 2 - BadNoCommunication, 3 - BadTypeMismatch, 4 - BadOutOfRange, 5 - BadWriteNotSupported, 7 - BadLicenseExpired, 8 - BadNotFound, 11 - BadUserAccessDenied, 12 - BadObjectDeleted, 13 - BadNodeIdUnknown, 14 - BadOutOfService)
- utcTime: Operation time in the UTC format
Please note that in order to perform the writing, it is necessary that the user specified on the Authorization tab (in Postman) has Write Value rights from the Data Access category of the role manager